--- /dev/null
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp 2015-07-28 06:06:23.000000000 +0000
+@@ -370,6 +370,16 @@ struct hs_longrun_thread_hs : public hs_
+ socket_args sockargs;
+ };
+
++struct lock_guard : noncopyable {
++ lock_guard(mutex& mtx) : mtx(mtx) {
++ mtx.lock();
++ }
++ ~lock_guard() {
++ mtx.unlock();
++ }
++ mutex& mtx;
++};
++
+ string_ref
+ to_string_ref(const std::string& s)
+ {
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/COPYING percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/COPYING
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/COPYING 1970-01-01 00:00:00.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/COPYING 2015-07-28 06:06:23.000000000 +0000
+@@ -0,0 +1,30 @@
++-----------------------------------------------------------------------------
++HandlerSocket plugin for MySQL
++
++ Copyright (c) 2010 DeNA Co.,Ltd.
++ All rights reserved.
++
++ Redistribution and use in source and binary forms, with or without
++ modification, are permitted provided that the following conditions are met:
++
++ * Redistributions of source code must retain the above copyright
++ notice, this list of conditions and the following disclaimer.
++ * Redistributions in binary form must reproduce the above copyright
++ notice, this list of conditions and the following disclaimer in the
++ documentation and/or other materials provided with the distribution.
++ * Neither the name of DeNA Co.,Ltd. nor the names of its contributors
++ may be used to endorse or promote products derived from this software
++ without specific prior written permission.
++
++ THIS SOFTWARE IS PROVIDED BY DeNA Co.,Ltd. "AS IS" AND ANY EXPRESS OR
++ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
++ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
++ EVENT SHALL DeNA Co.,Ltd. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
++ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
++ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
++ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
++ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++
++
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp 2015-07-28 06:06:23.000000000 +0000
+@@ -132,7 +132,6 @@ struct dbcontext : public dbcontext_i, p
+ virtual ~dbcontext();
+ virtual void init_thread(const void *stack_botton,
+ volatile int& shutdown_flag);
+- virtual void wait_for_server_to_start();
+ virtual void term_thread();
+ virtual bool check_alive();
+ virtual void lock_tables_if();
+@@ -232,6 +231,43 @@ dbcontext::~dbcontext()
+ {
+ }
+
++namespace {
++
++int
++wait_server_to_start(THD *thd, volatile int& shutdown_flag)
++{
++ int r = 0;
++ DBG_SHUT(fprintf(stderr, "HNDSOCK wsts\n"));
++ pthread_mutex_lock(&LOCK_server_started);
++ while (!mysqld_server_started) {
++ timespec abstime = { };
++ set_timespec(abstime, 1);
++ pthread_cond_timedwait(&COND_server_started, &LOCK_server_started,
++ &abstime);
++ pthread_mutex_unlock(&LOCK_server_started);
++ pthread_mutex_lock(&thd->mysys_var->mutex);
++ int killed = thd_killed(thd);
++ pthread_mutex_unlock(&thd->mysys_var->mutex);
++ DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d\n", killed));
++ pthread_mutex_lock(&LOCK_server_started);
++ if (killed) {
++ DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d break\n", killed));
++ r = -1;
++ break;
++ }
++ if (shutdown_flag) {
++ DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst shut break\n"));
++ r = -1;
++ break;
++ }
++ }
++ pthread_mutex_unlock(&LOCK_server_started);
++ DBG_SHUT(fprintf(stderr, "HNDSOCK wsts done\n"));
++ return r;
++}
++
++}; // namespace
++
+ #define DENA_THR_OFFSETOF(fld) ((char *)(&thd->fld) - (char *)thd)
+
+ void
+@@ -240,7 +276,7 @@ dbcontext::init_thread(const void *stack
+ DBG_THR(fprintf(stderr, "HNDSOCK init thread\n"));
+ {
+ my_thread_init();
+- thd = new THD(false);
++ thd = new THD;
+ thd->thread_stack = (char *)stack_bottom;
+ DBG_THR(fprintf(stderr,
+ "thread_stack = %p sizeof(THD)=%zu sizeof(mtx)=%zu "
+@@ -255,8 +291,7 @@ dbcontext::init_thread(const void *stack
+ DENA_THR_OFFSETOF(locked_tables_list)));
+ thd->store_globals();
+ thd->system_thread = static_cast<enum_thread_type>(1<<30UL);
+- NET v;
+- memset(&v, 0, sizeof(v));
++ const NET v = { 0 };
+ thd->net = v;
+ if (for_write_flag) {
+ #if MYSQL_VERSION_ID >= 50505
+@@ -283,6 +318,8 @@ dbcontext::init_thread(const void *stack
+ pthread_mutex_unlock(&LOCK_thread_count);
+ }
+
++ DBG_THR(fprintf(stderr, "HNDSOCK %p init thread wsts\n", thd));
++ wait_server_to_start(thd, shutdown_flag);
+ DBG_THR(fprintf(stderr, "HNDSOCK %p init thread done\n", thd));
+
+ thd_proc_info(thd, &info_message_buf[0]);
+@@ -294,15 +331,6 @@ dbcontext::init_thread(const void *stack
+ user_lock.reset(new expr_user_lock(thd, user_level_lock_timeout));
+ }
+
+-void
+-dbcontext::wait_for_server_to_start()
+-{
+- mysql_mutex_lock(&LOCK_server_started);
+- while (!mysqld_server_started)
+- mysql_cond_wait(&COND_server_started, &LOCK_server_started);
+- mysql_mutex_unlock(&LOCK_server_started);
+-}
+-
+ int
+ dbcontext::set_thread_message(const char *fmt, ...)
+ {
+@@ -318,25 +346,20 @@ void
+ dbcontext::term_thread()
+ {
+ DBG_THR(fprintf(stderr, "HNDSOCK thread end %p\n", thd));
+- unlock_tables_if();
++ close_tables_if();
+ my_pthread_setspecific_ptr(THR_THD, 0);
+ {
+ #if MYSQL_VERSION_ID >= 50600
+- thd->release_resources();
++ remove_global_thread(thd);
+ #endif
+- #if MYSQL_VERSION_ID < 50620
++
+ pthread_mutex_lock(&LOCK_thread_count);
+- #endif
+- #if MYSQL_VERSION_ID >= 50600
+- remove_global_thread(thd);
+- #else
++ #if MYSQL_VERSION_ID < 50600
+ --thread_count;
+ #endif
+ delete thd;
+ thd = 0;
+- #if MYSQL_VERSION_ID < 50620
+ pthread_mutex_unlock(&LOCK_thread_count);
+- #endif
+ my_thread_end();
+ }
+ }
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp 2015-07-28 06:06:23.000000000 +0000
+@@ -114,7 +114,6 @@ struct dbcontext_i {
+ virtual ~dbcontext_i() { }
+ virtual void init_thread(const void *stack_bottom,
+ volatile int& shutdown_flag) = 0;
+- virtual void wait_for_server_to_start() = 0;
+ virtual void term_thread() = 0;
+ virtual bool check_alive() = 0;
+ virtual void lock_tables_if() = 0;
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp 2015-07-28 06:06:23.000000000 +0000
+@@ -216,8 +216,7 @@ mysql_declare_plugin(handlersocket)
+ 0x0100 /* 1.0 */,
+ daemon_handlersocket_status_variables,
+ daemon_handlersocket_system_variables,
+- NULL,
+- 0,
++ 0
+ }
+ mysql_declare_plugin_end;
+
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp 2015-07-28 06:06:23.000000000 +0000
+@@ -54,7 +54,7 @@ namespace {
+ void
+ check_nfile(size_t nfile)
+ {
+- struct rlimit rl;
++ struct rlimit rl = { };
+ const int r = getrlimit(RLIMIT_NOFILE, &rl);
+ if (r != 0) {
+ fatal_abort("check_nfile: getrlimit failed");
+@@ -125,15 +125,6 @@ hstcpsvr::start_listen()
+ for (size_t i = 0; i < threads.size(); ++i) {
+ threads[i]->start();
+ }
+- {
+- lock_guard crit_sec(const_cast<mutex &>(vshared.v_mutex));
+- while (vshared.threads_started < cshared.num_threads) {
+- pthread_cond_wait(
+- const_cast<pthread_cond_t *>(&vshared.threads_started_cond),
+- (const_cast<mutex &>(vshared.v_mutex)).get());
+- }
+- }
+-
+ DENA_VERBOSE(20, fprintf(stderr, "threads started\n"));
+ return std::string();
+ }
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp 2015-07-28 06:06:23.000000000 +0000
+@@ -38,19 +38,9 @@ struct hstcpsvr_shared_c {
+ thread_num_conns(0) { }
+ };
+
+-struct hstcpsvr_shared_v : private noncopyable {
++struct hstcpsvr_shared_v : public mutex {
+ int shutdown;
+- long threads_started;
+- pthread_cond_t threads_started_cond;
+- mutex v_mutex;
+- hstcpsvr_shared_v() : shutdown(0), threads_started(0)
+- {
+- pthread_cond_init(&threads_started_cond, NULL);
+- }
+- ~hstcpsvr_shared_v()
+- {
+- pthread_cond_destroy(&threads_started_cond);
+- }
++ hstcpsvr_shared_v() : shutdown(0) { }
+ };
+
+ struct hstcpsvr_i;
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp 2015-07-28 06:06:23.000000000 +0000
+@@ -293,7 +293,9 @@ hstcpsvr_worker::hstcpsvr_worker(const h
+ if (epoll_fd.get() < 0) {
+ fatal_abort("epoll_create");
+ }
+- epoll_event ev = { EPOLLIN, { 0 } };
++ epoll_event ev = { };
++ ev.events = EPOLLIN;
++ ev.data.ptr = 0;
+ if (epoll_ctl(epoll_fd.get(), EPOLL_CTL_ADD, cshared.listen_fd.get(), &ev)
+ != 0) {
+ fatal_abort("epoll_ctl EPOLL_CTL_ADD");
+@@ -323,19 +325,7 @@ hstcpsvr_worker::run()
+ {
+ thr_init initobj(dbctx, vshared.shutdown);
+
+- {
+- lock_guard crit_sec(const_cast<mutex &>(vshared.v_mutex));
+- ++vshared.threads_started;
+- if (vshared.threads_started == cshared.num_threads)
+- {
+- pthread_cond_signal(
+- const_cast<pthread_cond_t *>(&vshared.threads_started_cond));
+- }
+- }
+-
+- dbctx->wait_for_server_to_start();
+-
+-#ifdef __linux__
++ #ifdef __linux__
+ if (cshared.sockargs.use_epoll) {
+ while (!vshared.shutdown && dbctx->check_alive()) {
+ run_one_ep();
+@@ -515,7 +505,7 @@ hstcpsvr_worker::run_one_ep()
+ if (fcntl(c->fd.get(), F_SETFL, O_NONBLOCK) != 0) {
+ fatal_abort("F_SETFL O_NONBLOCK");
+ }
+- epoll_event cev;
++ epoll_event cev = { };
+ cev.events = EPOLLIN | EPOLLOUT | EPOLLET;
+ cev.data.ptr = c.get();
+ c->nb_last_io = now;
+@@ -640,7 +630,9 @@ hstcpsvr_worker::run_one_ep()
+ total_num_conns * 2 > num_conns * cshared.num_threads) {
+ e_acc = true;
+ }
+- epoll_event ev = { EPOLLIN, { 0 } };
++ epoll_event ev = { };
++ ev.events = EPOLLIN;
++ ev.data.ptr = 0;
+ if (e_acc == accept_enabled) {
+ } else if (e_acc) {
+ if (epoll_ctl(epoll_fd.get(), EPOLL_CTL_ADD, cshared.listen_fd.get(), &ev)
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template 2015-07-28 06:06:23.000000000 +0000
+@@ -4,7 +4,7 @@ MYSQL_LIB = HANDLERSOCKET_MYSQL_LIB
+
+ CXX = g++ -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC
+ LIBS = $(MYSQL_LIB) -lhsclient -lpthread -lz
+-CXXFLAGS = -I/usr/include/handlersocket $(MYSQL_INC)
++CXXFLAGS = -I../libhsclient $(MYSQL_INC)
+ LDFLAGS =
+
+ CXXFLAGS += -O3 -DNDEBUG
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp 2015-07-28 06:06:23.000000000 +0000
+@@ -13,10 +13,7 @@
+ #define HAVE_CONFIG_H
+ #endif
+
+-#ifndef MYSQL_DYNAMIC_PLUGIN
+ #define MYSQL_DYNAMIC_PLUGIN
+-#endif
+-
+ #define MYSQL_SERVER 1
+
+ #include <my_config.h>
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp 2015-07-28 06:06:23.000000000 +0000
+@@ -9,7 +9,6 @@
+ #ifndef DENA_AUTO_ADDRINFO_HPP
+ #define DENA_AUTO_ADDRINFO_HPP
+
+-#include <cstring>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netdb.h>
+@@ -33,8 +32,7 @@ struct auto_addrinfo : private noncopyab
+ int resolve(const char *node, const char *service, int flags = 0,
+ int family = AF_UNSPEC, int socktype = SOCK_STREAM, int protocol = 0) {
+ reset();
+- addrinfo hints;
+- memset(&hints, 0, sizeof(hints));
++ addrinfo hints = { };
+ hints.ai_flags = flags;
+ hints.ai_family = family;
+ hints.ai_socktype = socktype;
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp 2015-07-28 06:06:23.000000000 +0000
+@@ -12,7 +12,7 @@
+ namespace dena {
+
+ template <typename Tcnt>
+-struct auto_ptrcontainer : private noncopyable {
++struct auto_ptrcontainer {
+ typedef Tcnt container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::pointer pointer;
+@@ -42,7 +42,9 @@ struct auto_ptrcontainer : private nonco
+ const_reference back() const { cnt.back(); }
+ void swap(auto_ptrcontainer& x) { cnt.swap(x.cnt); }
+ ~auto_ptrcontainer() {
+- clear();
++ for (iterator i = begin(); i != end(); ++i) {
++ delete *i;
++ }
+ }
+ template <typename Tap> void push_back_ptr(Tap& ap) {
+ cnt.push_back(ap.get());
+@@ -54,12 +56,7 @@ struct auto_ptrcontainer : private nonco
+ }
+ reference operator [](size_type n) { return cnt[n]; }
+ const_reference operator [](size_type n) const { return cnt[n]; }
+- void clear() {
+- for (iterator i = begin(); i != end(); i++) {
+- delete *i;
+- }
+- cnt.clear();
+- }
++ void clear() { cnt.clear(); }
+ private:
+ Tcnt cnt;
+ };
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp 2015-07-28 06:06:23.000000000 +0000
+@@ -41,23 +41,10 @@ struct mutex : private noncopyable {
+ fatal_abort("pthread_mutex_unlock");
+ }
+ }
+- pthread_mutex_t* get() const {
+- return &mtx;
+- }
+ private:
+ mutable pthread_mutex_t mtx;
+ };
+
+-struct lock_guard : noncopyable {
+- lock_guard(mutex& mtx) : mtx(mtx) {
+- mtx.lock();
+- }
+- ~lock_guard() {
+- mtx.unlock();
+- }
+- mutex& mtx;
+-};
+-
+ };
+
+ #endif
+diff -urNp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp
+--- percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp 2017-05-09 06:31:39.000000000 +0000
++++ percona-server-5.6.36-82.0/plugin/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp 2015-07-28 06:06:23.000000000 +0000
+@@ -80,9 +80,9 @@ int
+ socket_set_options(auto_file& fd, const socket_args& args, std::string& err_r)
+ {
+ if (args.timeout != 0 && !args.nonblocking) {
+- struct timeval tv;
+- memset(&tv, 0, sizeof(tv));
++ struct timeval tv = { };
+ tv.tv_sec = args.timeout;
++ tv.tv_usec = 0;
+ if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0) {
+ return errno_string("setsockopt SO_RCVTIMEO", errno, err_r);
+ }