MCPcopy Create free account
hub / github.com/git/git / client__multiple

Function client__multiple

t/helper/test-simple-ipc.c:533–577  ·  view source on GitHub ↗

* Start a client-side thread pool. Each thread sends a series of * IPC requests. Each request is on a new connection to the server. */

Source from the content-addressed store, hash-verified

531 * IPC requests. Each request is on a new connection to the server.
532 */
533static int client__multiple(void)
534{
535 struct multiple_thread_data *list = NULL;
536 int k;
537 int sum_join_errors = 0;
538 int sum_thread_errors = 0;
539 int sum_good = 0;
540
541 for (k = 0; k < cl_args.nr_threads; k++) {
542 struct multiple_thread_data *d = xcalloc(1, sizeof(*d));
543 d->next = list;
544 d->path = cl_args.path;
545 d->bytecount = cl_args.bytecount + cl_args.batchsize*(k/26);
546 d->batchsize = cl_args.batchsize;
547 d->sum_errors = 0;
548 d->sum_good = 0;
549 d->letter = 'A' + (k % 26);
550
551 if (pthread_create(&d->pthread_id, NULL, multiple_thread_proc, d)) {
552 warning("failed to create thread[%d] skipping remainder", k);
553 free(d);
554 break;
555 }
556
557 list = d;
558 }
559
560 while (list) {
561 struct multiple_thread_data *d = list;
562
563 if (pthread_join(d->pthread_id, NULL))
564 sum_join_errors++;
565
566 sum_thread_errors += d->sum_errors;
567 sum_good += d->sum_good;
568
569 list = d->next;
570 free(d);
571 }
572
573 printf("client (good %d) (join %d), (errors %d)\n",
574 sum_good, sum_join_errors, sum_thread_errors);
575
576 return (sum_join_errors + sum_thread_errors) ? 1 : 0;
577}
578
579int cmd__simple_ipc(int argc, const char **argv)
580{

Callers 1

cmd__simple_ipcFunction · 0.85

Calls 3

xcallocFunction · 0.85
pthread_createFunction · 0.85
warningFunction · 0.85

Tested by

no test coverage detected