X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fconnect.cc;h=6d9003770b039eaa30606d43280e2936e100dc44;hb=a83eb6704af40530cf38935cb30dd576af563e61;hp=3c82f641cb0f1f75fb12f12dceeb09ed4140b356;hpb=dc10a24219fcd6cfa2c33cae6a30449f72d579c1;p=awesomized%2Flibmemcached diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 3c82f641..6d900377 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -294,7 +294,7 @@ static bool set_socket_options(memcached_instance_st* server) // If SOCK_CLOEXEC exists then we don't need to call the following if (SOCK_CLOEXEC == 0) { - if (FD_CLOEXEC) + if (FD_CLOEXEC != 0) { int flags; do @@ -447,12 +447,12 @@ static memcached_return_t unix_socket_connect(memcached_instance_st* server) do { int type= SOCK_STREAM; - if (SOCK_CLOEXEC) + if (SOCK_CLOEXEC != 0) { type|= SOCK_CLOEXEC; } - if (SOCK_NONBLOCK) + if (SOCK_NONBLOCK != 0) { type|= SOCK_NONBLOCK; } @@ -466,7 +466,10 @@ static memcached_return_t unix_socket_connect(memcached_instance_st* server) memset(&servAddr, 0, sizeof (struct sockaddr_un)); servAddr.sun_family= AF_UNIX; - strncpy(servAddr.sun_path, server->hostname(), sizeof(servAddr.sun_path)); /* Copy filename */ + if (strlen(server->hostname()) >= sizeof(servAddr.sun_path)) { + return memcached_set_error(*server, MEMCACHED_UNIX_SOCKET_PATH_TOO_BIG, MEMCACHED_AT); + } + strncpy(servAddr.sun_path, server->hostname(), sizeof(servAddr.sun_path)-1); /* Copy filename */ if (connect(server->fd, (struct sockaddr *)&servAddr, sizeof(servAddr)) == -1) { @@ -542,12 +545,12 @@ static memcached_return_t network_connect(memcached_instance_st* server) } int type= server->address_info_next->ai_socktype; - if (SOCK_CLOEXEC) + if (SOCK_CLOEXEC != 0) { type|= SOCK_CLOEXEC; } - if (SOCK_NONBLOCK) + if (SOCK_NONBLOCK != 0) { type|= SOCK_NONBLOCK; } @@ -713,6 +716,7 @@ static memcached_return_t backoff_handling(memcached_instance_st* server, bool& if (_gettime_success and server->next_retry < curr_time.tv_sec) { server->state= MEMCACHED_SERVER_STATE_NEW; + server->server_timeout_counter= 0; } else {