| 2278 | #define ENQUEUE_DEQUEUE_DELAY 1 |
| 2279 | |
| 2280 | void Service::enqueue(const UCHAR* s, ULONG len) |
| 2281 | { |
| 2282 | if (checkForShutdown() || (svc_flags & SVC_detached)) |
| 2283 | { |
| 2284 | unblockQueryGet(); |
| 2285 | return; |
| 2286 | } |
| 2287 | |
| 2288 | while (len) |
| 2289 | { |
| 2290 | // Wait for space in buffer |
| 2291 | bool flagFirst = true; |
| 2292 | while (full()) |
| 2293 | { |
| 2294 | if (flagFirst) |
| 2295 | { |
| 2296 | unblockQueryGet(true); |
| 2297 | flagFirst = false; |
| 2298 | } |
| 2299 | svc_sem_empty.tryEnter(1, 0); |
| 2300 | if (checkForShutdown() || (svc_flags & SVC_detached)) |
| 2301 | { |
| 2302 | unblockQueryGet(); |
| 2303 | return; |
| 2304 | } |
| 2305 | } |
| 2306 | |
| 2307 | const ULONG head = svc_stdout_head; |
| 2308 | ULONG cnt = (head > svc_stdout_tail ? head : sizeof(svc_stdout)) - 1; |
| 2309 | if (add_one(cnt) != head) |
| 2310 | { |
| 2311 | ++cnt; |
| 2312 | } |
| 2313 | cnt -= svc_stdout_tail; |
| 2314 | if (cnt > len) |
| 2315 | { |
| 2316 | cnt = len; |
| 2317 | } |
| 2318 | |
| 2319 | memcpy(&svc_stdout[svc_stdout_tail], s, cnt); |
| 2320 | svc_stdout_tail = add_val(svc_stdout_tail, cnt); |
| 2321 | s += cnt; |
| 2322 | len -= cnt; |
| 2323 | } |
| 2324 | unblockQueryGet(); |
| 2325 | } |
| 2326 | |
| 2327 | |
| 2328 | void Service::unblockQueryGet(bool over) |
no test coverage detected