static int kclient_thread_connect(void *data) { int i, nconnects = 0; int threadn = (int)(long)data; int descidx = threadn * KCLIENT_NCONNECTS; SS_DBG("connect_thread_%02d started\n", threadn); for (i = 0; i < KCLIENT_NCONNECTS; i++) { if (kclient_connect(descidx + i) == 0) { nconnects++; } } kclient_connect_task[threadn] = NULL; atomic_dec(&kclient_nthreads); wake_up(&kclient_connect_wq); SS_DBG("Thread %d has initiated %d connects out of %d\n", threadn, nconnects, KCLIENT_NCONNECTS); return 0; }
/** * __start_client - Initiate connection with KServer * * Returns a pointer to a kclient structure * * Note: * __stop_client must be called to close the connection */ struct kclient* __start_client() { struct kclient *kcl; struct connection_cfg conn_cfg; if (get_config(&conn_cfg) < 0) { fprintf(stderr, "Error in configuration file\n"); return NULL; } if (conn_cfg.type == TCP) { kcl = kclient_connect(conn_cfg.ip, conn_cfg.port); } else if (conn_cfg.type == UNIX) { kcl = kclient_unix_connect(conn_cfg.sock_path); } else { fprintf(stderr, "Invalid connection type\n"); return NULL; } return kcl; }