quicwind/quicwind_proc.c
int quicwind_execute_work_item(picoquic_quic_t * qclient)
{
    int ret = 0;
    DWORD w_ret;
    quicwind_work_item_t * w = NULL;

    if (work_item_mutex == NULL) {
        AppendText(_T("Background thread is not ready.\r\n"));
        ret = -1;
    }
    else {
        w_ret = WaitForSingleObject(work_item_mutex, 1000);
        switch (w_ret) {
        case WAIT_OBJECT_0: {
            if (work_item_first != NULL) {
                w = work_item_first;
                work_item_first = w->next;
            }

            if (!ReleaseMutex(work_item_mutex)) {
                AppendText(_T("Thread cannot release the work item mutex.\r\n"));
            }
            break;
        }
        default:
            AppendText(_T("Cannot obtain the work item mutex.\r\n"));
            ret = -1;
            break;
        }
    }

    if (w != NULL) {
        switch (w->item_type) {
        case quicwind_work_item_connection:
            if (quicwind_start_connection(qclient,
                (w->name[0] != 0) ? w->name : NULL, (w->port[0] != 0) ? w->port : NULL,
                (w->doc[0] != 0 > 0) ? w->doc : NULL, (w->alpn[0] != 0) ? w->alpn : NULL,
                (w->sni[0] != 0) ? w->sni : NULL) != 0) {
                AppendText(_T("Could not create the connection.\r\n"));
            }
            else {
                AppendText(_T("Created a connection\r\n"));
            }
            break;
        case quicwind_work_item_load_file:
            if (quicwind_load_file(qclient, w->sel_cid, w->doc) != 0) {
                AppendText(_T("Something happened, could not request the document.\r\n"));
            }
            break;
        case quicwind_work_item_disconnect:
            if (quicwind_disconnect(qclient, w->sel_cid) != 0) {
                AppendText(_T("Something happened, could not close the connection.\r\n"));
            }
            break;
        default:
            AppendText(_T("Thread found unknown item type.\r\n"));
            break;
        }
        free(w);
    }

    return ret;
}
/* Consume the first work item in the queue */
Consume the first work item in the queue
Consume the first work item in the queue
int quicwind_execute_work_item(picoquic_quic_t * qclient)
{
    int ret = 0;
    DWORD w_ret;
    quicwind_work_item_t * w = NULL;
    if (work_item_mutex == NULL) {
        AppendText(_T("Background thread is not ready.\r\n"));
        ret = -1;
    }
    else {
        w_ret = WaitForSingleObject(work_item_mutex, 1000);
        switch (w_ret) {
        case WAIT_OBJECT_0: {
            if (work_item_first != NULL) {
                w = work_item_first;
                work_item_first = w->next;
            }
            if (!ReleaseMutex(work_item_mutex)) {
                AppendText(_T("Thread cannot release the work item mutex.\r\n"));
            }
            break;
        }
        default:
            AppendText(_T("Cannot obtain the work item mutex.\r\n"));
            ret = -1;
            break;
        }
    }
    if (w != NULL) {
        switch (w->item_type) {
        case quicwind_work_item_connection:
            if (quicwind_start_connection(qclient,
                (w->name[0] != 0) ? w->name : NULL, (w->port[0] != 0) ? w->port : NULL,
                (w->doc[0] != 0 > 0) ? w->doc : NULL, (w->alpn[0] != 0) ? w->alpn : NULL,
                (w->sni[0] != 0) ? w->sni : NULL) != 0) {
                AppendText(_T("Could not create the connection.\r\n"));
            }
            else {
                AppendText(_T("Created a connection\r\n"));
            }
            break;
        case quicwind_work_item_load_file:
            if (quicwind_load_file(qclient, w->sel_cid, w->doc) != 0) {
                AppendText(_T("Something happened, could not request the document.\r\n"));
            }
            break;
        case quicwind_work_item_disconnect:
            if (quicwind_disconnect(qclient, w->sel_cid) != 0) {
                AppendText(_T("Something happened, could not close the connection.\r\n"));
            }
            break;
        default:
            AppendText(_T("Thread found unknown item type.\r\n"));
            break;
        }
        free(w);
    }
    return ret;
}
int quicwind_execute_work_item ( picoquic_quic_t * qclient ) { int ret = 0 ; DWORD w_ret ; quicwind_work_item_t * w = NULL ; if ( work_item_mutex == NULL ) { AppendText ( _T ( " \r \n " ) ) ; ret = -1 ; } else { w_ret = WaitForSingleObject ( work_item_mutex , 1000 ) ; switch ( w_ret ) { case WAIT_OBJECT_0 : { if ( work_item_first != NULL ) { w = work_item_first ; work_item_first = w -> next ; } if ( ! ReleaseMutex ( work_item_mutex ) ) { AppendText ( _T ( " \r \n " ) ) ; } break ; } default : AppendText ( _T ( " \r \n " ) ) ; ret = -1 ; break ; } } if ( w != NULL ) { switch ( w -> item_type ) { case quicwind_work_item_connection : if ( quicwind_start_connection ( qclient , ( w -> name [ 0 ] != 0 ) ? w -> name : NULL , ( w -> port [ 0 ] != 0 ) ? w -> port : NULL , ( w -> doc [ 0 ] != 0 > 0 ) ? w -> doc : NULL , ( w -> alpn [ 0 ] != 0 ) ? w -> alpn : NULL , ( w -> sni [ 0 ] != 0 ) ? w -> sni : NULL ) != 0 ) { AppendText ( _T ( " \r \n " ) ) ; } else { AppendText ( _T ( " \r \n " ) ) ; } break ; case quicwind_work_item_load_file : if ( quicwind_load_file ( qclient , w -> sel_cid , w -> doc ) != 0 ) { AppendText ( _T ( " \r \n " ) ) ; } break ; case quicwind_work_item_disconnect : if ( quicwind_disconnect ( qclient , w -> sel_cid ) != 0 ) { AppendText ( _T ( " \r \n " ) ) ; } break ; default : AppendText ( _T ( " \r \n " ) ) ; break ; } free ( w ) ; } return ret ; }
Consume the first work item in the queue
Consume the first work item in the queue