| 33 | using std::ostringstream; |
| 34 | |
| 35 | const char* get_rand_socket_path() |
| 36 | { |
| 37 | static char *g_socket_path = NULL; |
| 38 | |
| 39 | if (g_socket_path == NULL) { |
| 40 | char buf[512]; |
| 41 | const char *tdir = getenv("TMPDIR"); |
| 42 | #ifdef _WIN32 |
| 43 | if (tdir == NULL) { |
| 44 | tdir = getenv("TEMP"); |
| 45 | } |
| 46 | #endif /* _WIN32 */ |
| 47 | if (tdir == NULL) { |
| 48 | tdir = "/tmp"; |
| 49 | } |
| 50 | snprintf(buf, sizeof(((struct sockaddr_un*)0)->sun_path), |
| 51 | "%s/perfcounters_test_socket.%ld.%ld", |
| 52 | tdir, (long int)getpid(), time(NULL)); |
| 53 | g_socket_path = (char*)strdup(buf); |
| 54 | } |
| 55 | return g_socket_path; |
| 56 | } |
| 57 | |
| 58 | static std::string asok_connect(const std::string &path, int *fd) |
| 59 | { |