X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Futil%2Fpid.cc;h=2d7a86ddd8a18c6e9b6d9cc0a8f2511ae05917ed;hb=e4e6bde654ddb9017f090f3a36d6e9f5fd70b354;hp=d9ba79c7b28bdd36aee9251fe1b8e83435296082;hpb=12a07e58df95bb8dbe167e4157b29c910177ade8;p=m6w6%2Flibmemcached diff --git a/libmemcached/util/pid.cc b/libmemcached/util/pid.cc index d9ba79c7..2d7a86dd 100644 --- a/libmemcached/util/pid.cc +++ b/libmemcached/util/pid.cc @@ -56,31 +56,32 @@ pid_t libmemcached_util_getpid(const char *hostname, in_port_t port, memcached_r if (not memc_ptr) { *ret= MEMCACHED_MEMORY_ALLOCATION_FAILURE; - return pid; + return -1; } memcached_return_t rc= memcached_server_add(memc_ptr, hostname, port); if (memcached_success(rc)) { memcached_stat_st *stat= memcached_stat(memc_ptr, NULL, &rc); - if (stat and stat->pid > 0) + if (memcached_success(rc) and stat and stat->pid != -1) { pid= stat->pid; } - else if (memcached_failed(rc) and rc == MEMCACHED_SOME_ERRORS) + else if (memcached_success(rc)) + { + rc= MEMCACHED_UNKNOWN_STAT_KEY; // Something went wrong if this happens + } + else if (rc == MEMCACHED_SOME_ERRORS) // Generic answer, we will now find the specific reason (if one exists) { memcached_server_instance_st instance= memcached_server_instance_by_position(memc_ptr, 0); + assert_msg(instance and instance->error_messages, " "); if (instance and instance->error_messages) { rc= memcached_server_error_return(instance); } } - else if (memcached_success(rc)) - { - rc= MEMCACHED_UNKNOWN_STAT_KEY; // Something went wrong if this happens - } memcached_stat_free(memc_ptr, stat); }