| 402 | } |
| 403 | |
| 404 | static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) { |
| 405 | client c = (client)privdata; |
| 406 | UNUSED(el); |
| 407 | UNUSED(fd); |
| 408 | UNUSED(mask); |
| 409 | |
| 410 | /* Initialize request when nothing was written. */ |
| 411 | if (c->written == 0) { |
| 412 | /* Really initialize: randomize keys and set start time. */ |
| 413 | if (config.randomkeys) randomizeClientKey(c); |
| 414 | atomicGet(config.slots_last_update, c->slots_last_update); |
| 415 | c->start = ustime(); |
| 416 | c->latency = -1; |
| 417 | } |
| 418 | if (sdslen(c->obuf) > c->written) { |
| 419 | void *ptr = c->obuf+c->written; |
| 420 | ssize_t nwritten = write(c->context->fd,ptr,sdslen(c->obuf)-c->written); |
| 421 | if (nwritten == -1) { |
| 422 | if (errno != EPIPE) |
| 423 | fprintf(stderr, "Writing to socket: %s\n", strerror(errno)); |
| 424 | freeClient(c); |
| 425 | return; |
| 426 | } |
| 427 | c->written += nwritten; |
| 428 | if (sdslen(c->obuf) == c->written) { |
| 429 | aeDeleteFileEvent(el,c->context->fd,AE_WRITABLE); |
| 430 | aeCreateFileEvent(el,c->context->fd,AE_READABLE,readHandler,c); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | /* Create a benchmark client, configured to send the command passed as 'cmd' of |
| 436 | * 'len' bytes. |
nothing calls this directly
no test coverage detected