void TerminateGUI (int rcByGUI) { DestroyDskMsgQueue (); DestroyFreeQMSGList (); TerminateDesktop (); TerminateAccel (); TerminateControlClass (); TerminateMenu (); #ifdef _CURSOR_SUPPORT TerminateCursor (); #endif TerminateFixStr (); #ifdef _STAND_ALONE SendMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0); StandAloneCleanup (); #else if (mgIsServer) { SendMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0); /* Cleanup UNIX domain socket and other IPC objects. */ ServerCleanup (); } else { ClientCleanup (); } #endif }
void NamedPipe::Cleanup() { if (m_cleanupActive.test_and_set()) return; ServerCleanup(); }
PRIVATE int ServEvent (SOCKET soc, void * pVoid, HTEventType type) { https_info * http = (https_info *)pVoid; int status = HT_ERROR; HTNet * net = http->net; HTRequest * request = HTNet_request(net); if (!net || !request) { HTTRACE(PROT_TRACE, "Serv HTTP... Invalid argument\n"); return HT_ERROR; } if (type == HTEvent_CLOSE) { /* Interrupted */ ServerCleanup(request, net, HT_INTERRUPTED); return HT_OK; } else http = (https_info *) HTNet_context(net); /* Get existing copy */ /* Now jump into the machine. We know the state from the previous run */ while (1) { switch (http->state) { case HTTPS_BEGIN: { /* ** Create the request to handle the request and inherit the old ** context */ HTRequest * client = HTRequest_new(); void * context = HTRequest_context(request); if (context) HTRequest_setContext(client, context); HTRequest_setOutputConnected(client, NO); HTRequest_setGnHd(client, HTRequest_gnHd(request)); HTRequest_setRsHd(client, HTRequest_rsHd(request)); HTRequest_setEnHd(client, HTRequest_enHd(request)); HTList_addObject(http->clients, client); /* ** Create the HTTP output stream for generating the reply ** FROM the client request to the channel */ { HTOutputStream * output = HTNet_getOutput(net, NULL, 0); HTStream * app = HTTPReply_new(client, http,(HTStream*)output); HTRequest_setOutputStream(client, app); HTRequest_setOutputFormat(client, WWW_SOURCE); } http->state = HTTPS_NEED_REQUEST; } break; case HTTPS_NEED_REQUEST: if (type == HTEvent_READ || type == HTEvent_BEGIN) { status = HTHost_read(net->host, net); if (status == HT_WOULD_BLOCK) return HT_OK; else if (status == HT_CLOSED) http->state = HTTPS_OK; else if (status==HT_LOADED || status==HT_PAUSE) { http->state = HTTPS_LOAD_CLIENT; } else http->state = HTTPS_ERROR; } else http->state = HTTPS_ERROR; break; case HTTPS_LOAD_CLIENT: { HTRequest * client = HTList_removeFirstObject(http->clients); HTLoad(client, NO); http->state = HTTPS_BEGIN; break; } case HTTPS_OK: ServerCleanup(request, net, HT_IGNORE); return HT_OK; case HTTPS_ERROR: ServerCleanup(request, net, HT_ERROR); return HT_OK; } } }