Permalink
Browse files

allow disabling pthreads for testing

  • Loading branch information...
1 parent bb502fa commit 5c0fd7b976b8fb1271dbe61b9ea456672ab5b370 @chris-y committed Jun 9, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 examples/network/fetch.c
View
@@ -36,7 +36,9 @@ static void *download(void *ptr)
exit:
data->finished = 1;
+#ifndef NO_PTHREADS
pthread_exit(&data->ret);
+#endif
}
int update_cb(const char *refname, const git_oid *a, const git_oid *b)
@@ -81,6 +83,9 @@ int fetch(git_repository *repo, int argc, char **argv)
data.finished = 0;
memset(&stats, 0, sizeof(stats));
+#ifdef NO_PTHREADS
+ download(&data);
+#else
pthread_create(&worker, NULL, download, &data);
// Loop while the worker thread is still running. Here we show processed
@@ -91,6 +96,7 @@ int fetch(git_repository *repo, int argc, char **argv)
usleep(10000);
printf("\rReceived %d/%d objects in %d bytes", stats.processed, stats.total, bytes);
} while (!data.finished);
+#endif
printf("\rReceived %d/%d objects in %d bytes\n", stats.processed, stats.total, bytes);
// Disconnect the underlying connection to prevent from idling.

0 comments on commit 5c0fd7b

Please sign in to comment.