ULONG QueueQuery( PUCHAR name, ULONG argc, PRXSTRING args, PSZ queue, PRXSTRING result) { HQUEUE handle; PQueue q; PRXSTRING elementsVar; ULONG elements; APIRET rc; ULONG cc; if (argc != 2) return QUEUE_BADPARAM; if (!RxStringToUnsigned(args + 0, &handle)) return QUEUE_BADPARAM; q = (PQueue)handle; if (!RxStringIsPresent(args + 1)) return QUEUE_BADPARAM; elementsVar = args + 1; rc = DosQueryQueue(q->handle, &elements); if (rc == NO_ERROR) { UnsignedToRxVariable(elements, elementsVar); } cc = UnsignedToRxResult(rc, result); return cc; }
int os2KbdQueueQuery() { ULONG numElements,postCount; (void)DosQueryQueue(hKbdQueue,&numElements); if (numElements!=0) return 0; /* We have something in queue */ DosResetEventSem(hKbdSem,&postCount); return 1; }
static void server_maintenance(void *vpArg) { int num_idle, num_needed; ULONG num_pending = 0; int threadnum; HQUEUE workq; ULONG rc; PID owner; rc = DosOpenQueue(&owner, &workq, apr_psprintf(pchild, "/queues/httpd/work.%d", getpid())); if (rc) { ap_log_error(APLOG_MARK, APLOG_ERR, APR_FROM_OS_ERROR(rc), ap_server_conf, "unable to open work queue in maintenance thread"); return; } do { for (num_idle=0, threadnum=0; threadnum < HARD_THREAD_LIMIT; threadnum++) { num_idle += ap_scoreboard_image->servers[child_slot][threadnum].status == SERVER_READY; } DosQueryQueue(workq, &num_pending); num_needed = ap_min_spare_threads - num_idle + num_pending; if (num_needed > 0) { for (threadnum=0; threadnum < num_needed; threadnum++) { add_worker(); } } if (num_idle - num_pending > ap_max_spare_threads) { DosWriteQueue(workq, WORKTYPE_EXIT, 0, NULL, 0); } } while (DosWaitEventSem(shutdown_event, 500) == ERROR_TIMEOUT); }