diff --git a/If-connect-fails-let-other-side-accept-connection-and-come-back.patch b/If-connect-fails-let-other-side-accept-connection-and-come-back.patch new file mode 100644 index 0000000..bf1d79c --- /dev/null +++ b/If-connect-fails-let-other-side-accept-connection-and-come-back.patch @@ -0,0 +1,100 @@ +From: Egbert Eich +Date: Wed Jul 18 11:26:07 2018 +0200 +Subject: If connect fails let other side accept connection and come back +Patch-mainline: Not yet +Git-commit: 1fc96affadb267bb03058293e9d31af95cfd6f2d +References: bsc# + +The UNIX socket code uses inotify to get notified when a socket +it monitors appears. The inotify is triggered when the other side +does bind(). However, we are not able to connect until the other +side calls listen(). Therefore, we need to let the other side continue +if the connect fails and should come back at the earliest time to +attempt a connect() again. +For this we just reset the poll() delay. + +Signed-off-by: Egbert Eich +--- + server-unixsock.c | 22 ++++++++++++++++++---- + 1 file changed, 18 insertions(+), 4 deletions(-) +diff --git a/server-unixsock.c b/server-unixsock.c +index 152bd31..7302acf 100644 +--- a/server-unixsock.c ++++ b/server-unixsock.c +@@ -46,8 +46,10 @@ + + + static size_t max_unixsock_dev_strlen(void); ++static int connect_unixsock_obj_int(obj_t *unixsock, int reset_delay); + static int connect_unixsock_obj(obj_t *unixsock); + static int disconnect_unixsock_obj(obj_t *unixsock); ++static int open_unixsock_obj_reset_delay(obj_t *unixsock); + static void reset_unixsock_delay(obj_t *unixsock); + + extern tpoll_t tp_global; /* defined in server.c */ +@@ -147,7 +149,7 @@ obj_t * create_unixsock_obj(server_conf_t *conf, char *name, char *dev, + list_append(conf->objs, unixsock); + + rv = inevent_add(unixsock->aux.unixsock.dev, +- (inevent_cb_f) open_unixsock_obj, unixsock); ++ (inevent_cb_f) open_unixsock_obj_reset_delay, unixsock); + if (rv < 0) { + log_msg(LOG_INFO, + "Console [%s] unable to register device \"%s\" for inotify events", +@@ -157,7 +159,7 @@ obj_t * create_unixsock_obj(server_conf_t *conf, char *name, char *dev, + } + + +-int open_unixsock_obj(obj_t *unixsock) ++static int open_unixsock_obj_int(obj_t *unixsock, int reset_delay) + { + /* (Re)opens the specified 'unixsock' obj. + * Returns 0 if the console is successfully opened; o/w, returns -1. +@@ -171,11 +173,18 @@ int open_unixsock_obj(obj_t *unixsock) + rc = disconnect_unixsock_obj(unixsock); + } + else { +- rc = connect_unixsock_obj(unixsock); ++ rc = connect_unixsock_obj_int(unixsock, reset_delay); + } + return(rc); + } + ++int open_unixsock_obj(obj_t *unixsock) { ++ return open_unixsock_obj_int(unixsock, 0); ++} ++ ++int open_unixsock_obj_reset_delay(obj_t *unixsock) { ++ return open_unixsock_obj_int(unixsock, 1); ++} + + static size_t max_unixsock_dev_strlen(void) + { +@@ -193,7 +202,7 @@ static size_t max_unixsock_dev_strlen(void) + } + + +-static int connect_unixsock_obj(obj_t *unixsock) ++static int connect_unixsock_obj_int(obj_t *unixsock, int reset_delay) + { + /* Opens a connection to the specified (unixsock) obj. + * Returns 0 if the connection is successfully completed; o/w, returns -1. +@@ -257,6 +266,8 @@ static int connect_unixsock_obj(obj_t *unixsock) + (struct sockaddr *) &saddr, sizeof(saddr)) < 0) { + log_msg(LOG_INFO, "Console [%s] cannot connect to device \"%s\": %s", + unixsock->name, auxp->dev, strerror(errno)); ++ if (reset_delay) ++ reset_unixsock_delay(unixsock); + return(disconnect_unixsock_obj(unixsock)); + } + /* Write-locking the unix domain socket appears ineffective. But since +@@ -284,6 +295,9 @@ static int connect_unixsock_obj(obj_t *unixsock) + return(0); + } + ++static int connect_unixsock_obj(obj_t *unixsock) { ++ return connect_unixsock_obj_int(unixsock, 0); ++} + + static int disconnect_unixsock_obj(obj_t *unixsock) + { diff --git a/conman.changes b/conman.changes index 58ed269..420bb4c 100644 --- a/conman.changes +++ b/conman.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Wed Jul 18 13:08:03 UTC 2018 - eich@suse.com + +- If-connect-fails-let-other-side-accept-connection-and-come-back.patch: + Make sure conmand connects to a newly created UNIX socket with + minimal delay. The implementation uses inotify, however this triggers + when the other side bind()s to the socket, however a connection is + not possible until the other side calls listen(). + Thus if the connection fails, reset the poll() timeout to return to + connect() as soon as possible (bsc#1101647). +- Support %license in a backward compatible way. + ------------------------------------------------------------------- Thu Mar 8 20:14:50 UTC 2018 - eich@suse.com diff --git a/conman.spec b/conman.spec index 0f35069..ca90bbc 100644 --- a/conman.spec +++ b/conman.spec @@ -48,7 +48,7 @@ Version: 0.2.8 Release: 0 Summary: The Console Manager -License: GPL-3.0+ +License: GPL-3.0-or-later Group: System/Console Url: http://dun.github.io/conman/ @@ -69,6 +69,7 @@ Requires(pre): shadow %endif Patch1: conman-suse-fix-expect-scripts.patch +Patch2: If-connect-fails-let-other-side-accept-connection-and-come-back.patch # 8/15/14 karl.w.schulz@intel.com - include prereq %if 0%{?sles_version} || 0%{?suse_version} @@ -93,6 +94,7 @@ Its features include: %prep %setup -q -n %{name}-%{name}-%{version} %patch1 -p1 +%patch2 -p1 %build %configure --with-tcp-wrappers \ @@ -219,12 +221,18 @@ touch %_localstatedir/lib/conman/%migrated || : %{restart_on_update conman} %endif +%if 0%{?sle_version} > 120200 || 0%{?suse_version} > 1320 +%define files_license %license +%else +%define files_license %doc +%endif + %files %defattr(-,root,root,-) %doc AUTHORS %doc DISCLAIMER* %doc FAQ -%doc COPYING +%files_license COPYING %doc NEWS %doc README %doc PLATFORMS