On Mon, 2016-02-22 at 12:33 +0100, Christoph Berg wrote:
> Re: Svante Signell 2016-02-20 <1455998664.2888.77.ca...@gmail.com>
> > On Sat, 2016-02-20 at 20:21 +0100, Christoph Berg wrote:
> > > Hi,
> > > 
> > > Just a quick note here - the signal being sent here is from sbuild
> > > killing the process because it was stuck for four hours. The problem
> > > is that the sem syscall doesn't return.
> > 
> > Iv'e come a little further: The error code is due to ETIMEDOUT as
> > expected. A new patch will probably follow tomorrow. Thanks!
> 
> Hi,
> 
> I've done some digging as well:
> 
> int main() {
> sem_t sem;
> struct timespec ts = {0, 0};
> if (sem_init(&sem, 0, 0) == -1) {
>         perror ("sem_init");
>         return -1;
> }
> if (sem_timedwait(&sem, &ts)==-1) {
>         perror ("sem_timedwait");
>         return -2;
> }
> return 0;
> }
> 
> sem_timedwait: Connection timed out
> 
> From what I got from the manpages, ts should probably be initialized
> as I've done above. What seems to work is to initialize the semaphore
> to 1, but then I have absolutely no experience with semaphores, nor
> what this test should actually test.

Hi Christoph. I've found out that the test for sem_timedwait is not needed.
There is a program in the manpage that works well in Hurd too. Attached is an
updated patch. This patch and a follow-up patch on bug #803776 will be submitted
upstream ASAP.

Index: libqb-0.17.2.real/configure.ac
===================================================================
--- libqb-0.17.2.real.orig/configure.ac
+++ libqb-0.17.2.real/configure.ac
@@ -341,6 +341,11 @@ case "$host_os" in
 		CP=rsync
 		AC_MSG_RESULT([Solaris])
 	;;
+	*gnu*)
+		AC_DEFINE_UNQUOTED([QB_GNU], [1],
+				   [Compiling for GNU/Hurd platform])
+		AC_MSG_RESULT([GNU])
+	;;
 	*)
 		AC_MSG_ERROR([Unsupported OS? hmmmm])
 	;;
Index: libqb-0.17.2.real/lib/log_thread.c
===================================================================
--- libqb-0.17.2.real.orig/lib/log_thread.c
+++ libqb-0.17.2.real/lib/log_thread.c
@@ -164,7 +164,11 @@ qb_log_thread_start(void)
 
 	if (logt_sched_param_queued) {
 		res = qb_log_thread_priority_set(logt_sched_policy,
+#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX)
 		                                 logt_sched_param.sched_priority);
+#else
+		                                 0);
+#endif
 		if (res != 0) {
 			goto cleanup_pthread;
 		}
Index: libqb-0.17.2.real/lib/ipc_socket.c
===================================================================
--- libqb-0.17.2.real.orig/lib/ipc_socket.c
+++ libqb-0.17.2.real/lib/ipc_socket.c
@@ -50,7 +50,7 @@ set_sock_addr(struct sockaddr_un *addres
 	address->sun_len = QB_SUN_LEN(address);
 #endif
 
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
+#if defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU)
 	snprintf(address->sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
 #else
 	snprintf(address->sun_path, sizeof(address->sun_path), "%s/%s", SOCKETDIR,
@@ -79,7 +79,7 @@ qb_ipc_dgram_sock_setup(const char *base
 	}
 	snprintf(sock_path, PATH_MAX, "%s-%s", base_name, service_name);
 	set_sock_addr(&local_address, sock_path);
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
+#if !(defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU))
 	res = unlink(local_address.sun_path);
 #endif
 	res = bind(request_fd, (struct sockaddr *)&local_address,
@@ -287,7 +287,7 @@ _finish_connecting(struct qb_ipc_one_way
 static void
 qb_ipcc_us_disconnect(struct qb_ipcc_connection *c)
 {
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
+#if !(defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU))
   struct sockaddr_un un_addr;
   socklen_t un_addr_len = sizeof(struct sockaddr_un);
   char *base_name;
@@ -298,7 +298,7 @@ qb_ipcc_us_disconnect(struct qb_ipcc_con
 	munmap(c->request.u.us.shared_data, SHM_CONTROL_SIZE);
 	unlink(c->request.u.us.shared_file_name);
 
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
+#if !(defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU))
     if (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {
       length = strlen(un_addr.sun_path);
       base_name = strndup(un_addr.sun_path,length-9);
@@ -422,7 +422,7 @@ retry_peek:
 
 		if (errno != EAGAIN) {
 			final_rc = -errno;
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
+#if !(defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU))
 			if (errno == ECONNRESET || errno == EPIPE) {
 				final_rc = -ENOTCONN;
 			}
@@ -657,7 +657,7 @@ _sock_rm_from_mainloop(struct qb_ipcs_co
 static void
 qb_ipcs_us_disconnect(struct qb_ipcs_connection *c)
 {
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
+#if !(defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU))
 	struct sockaddr_un un_addr;
 	socklen_t un_addr_len = sizeof(struct sockaddr_un);
 	char *base_name;
@@ -670,7 +670,7 @@ qb_ipcs_us_disconnect(struct qb_ipcs_con
 	    c->state == QB_IPCS_CONNECTION_ACTIVE) {
 		_sock_rm_from_mainloop(c);
 
-#if !(defined(QB_LINUX) || defined(QB_CYGWIN))
+#if !(defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU))
 		if (getsockname(c->response.u.us.sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) {
 			length = strlen(un_addr.sun_path);
 			base_name = strndup(un_addr.sun_path,length-8);
Index: libqb-0.17.2.real/lib/unix.c
===================================================================
--- libqb-0.17.2.real.orig/lib/unix.c
+++ libqb-0.17.2.real/lib/unix.c
@@ -80,7 +80,7 @@ qb_sys_mmap_file_open(char *path, const
 	if (is_absolute) {
 		(void)strlcpy(path, file, PATH_MAX);
 	} else {
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
+#if defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU)
 		snprintf(path, PATH_MAX, "/dev/shm/%s", file);
 #else
 		snprintf(path, PATH_MAX, LOCALSTATEDIR "/run/%s", file);
Index: libqb-0.17.2.real/lib/ipc_setup.c
===================================================================
--- libqb-0.17.2.real.orig/lib/ipc_setup.c
+++ libqb-0.17.2.real/lib/ipc_setup.c
@@ -282,7 +282,7 @@ qb_ipcc_stream_sock_connect(const char *
 	address.sun_len = QB_SUN_LEN(&address);
 #endif
 
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
+#if defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU)
 	snprintf(address.sun_path + 1, UNIX_PATH_MAX - 1, "%s", socket_name);
 #else
 	snprintf(address.sun_path, sizeof(address.sun_path), "%s/%s", SOCKETDIR,
@@ -394,7 +394,7 @@ qb_ipcs_us_publish(struct qb_ipcs_servic
 #endif
 
 	qb_util_log(LOG_INFO, "server name: %s", s->name);
-#if defined(QB_LINUX) || defined(QB_CYGWIN)
+#if defined(QB_LINUX) || defined(QB_CYGWIN) || defined(QB_GNU)
 	snprintf(un_addr.sun_path + 1, UNIX_PATH_MAX - 1, "%s", s->name);
 #else
 	{
@@ -426,7 +426,7 @@ qb_ipcs_us_publish(struct qb_ipcs_servic
 	 * Allow everyone to write to the socket since the IPC layer handles
 	 * security automatically
 	 */
-#if !defined(QB_LINUX) && !defined(QB_CYGWIN)
+#if !defined(QB_LINUX) && !defined(QB_CYGWIN) && !defined(QB_GNU)
 	res = chmod(un_addr.sun_path, S_IRWXU | S_IRWXG | S_IRWXO);
 #endif
 #ifdef SO_PASSCRED

Reply via email to