X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fms_thread.c;h=dbfc62a7965194bc49c9c92f0527e15a239054f2;hb=cc097580e5e0af9ea2626e110ae418f81b8af7a8;hp=af856366c345ddea87ddbc9f2fd0a7693155d92c;hpb=ad624f93ee91351c4f3839ca0dc1a9981644d391;p=awesomized%2Flibmemcached diff --git a/clients/ms_thread.c b/clients/ms_thread.c index af856366..dbfc62a7 100644 --- a/clients/ms_thread.c +++ b/clients/ms_thread.c @@ -11,6 +11,16 @@ #include "config.h" +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif #include "ms_thread.h" #include "ms_setting.h" #include "ms_atomic.h" @@ -61,7 +71,7 @@ static void ms_check_sock_timeout(void) if (c->udp) { - time_diff= (int)(ms_thread->curr_time - c->start_time.tv_sec); + time_diff= (int)(ms_thread->curr_time - (rel_time_t)c->start_time.tv_sec); /* wait time out */ if (time_diff > SOCK_WAIT_TIMEOUT) @@ -69,10 +79,10 @@ static void ms_check_sock_timeout(void) /* calculate dropped packets count */ if (c->recvpkt > 0) { - atomic_add_64(&ms_stats.pkt_drop, c->packets - c->recvpkt); + atomic_add_size(&ms_stats.pkt_drop, c->packets - c->recvpkt); } - atomic_add_64(&ms_stats.udp_timeout, 1); + atomic_add_size(&ms_stats.udp_timeout, 1); ms_reset_conn(c, true); } } @@ -169,7 +179,7 @@ static int ms_set_thread_cpu_affinity(int cpu) */ static int ms_setup_thread(ms_thread_ctx_t *thread_ctx) { - + ms_thread_t *ms_thread= (ms_thread_t *)calloc(sizeof(*ms_thread), 1); pthread_setspecific(ms_thread_key, (void *)ms_thread); @@ -297,7 +307,7 @@ void ms_thread_init() for (int i= 0; i < ms_setting.nthreads; i++) { ms_thread_ctx[i].thd_idx= i; - ms_thread_ctx[i].nconns= ms_setting.nconns / ms_setting.nthreads; + ms_thread_ctx[i].nconns= (int)((int)ms_setting.nconns / ms_setting.nthreads); /** * If only one server, all the connections in all threads @@ -306,7 +316,7 @@ void ms_thread_init() */ ms_thread_ctx[i].srv_idx= i % ms_setting.srv_cnt; ms_thread_ctx[i].tps_perconn= ms_setting.expected_tps - / ms_setting.nconns; + / (int)ms_setting.nconns; ms_thread_ctx[i].exec_num_perconn= ms_setting.exec_num / ms_setting.nconns; }