Dr. Werner Fink 2011-10-05 09:49:25 +00:00 committed by Git OBS Bridge
parent 9e76689168
commit 25cf8e9598
3 changed files with 27 additions and 11 deletions

View File

@ -120,7 +120,7 @@ diff --git a/src/timeout.c b/src/timeout.c
index e69de29..3b582a3 100644 index e69de29..3b582a3 100644
--- a/src/timeout.c --- a/src/timeout.c
+++ b/src/timeout.c +++ b/src/timeout.c
@@ -0,0 +1,208 @@ @@ -0,0 +1,215 @@
+/* +/*
+ * timout.c Advanced timeout handling for file system calls + * timout.c Advanced timeout handling for file system calls
+ * to avoid deadlocks on remote file shares. + * to avoid deadlocks on remote file shares.
@ -141,6 +141,8 @@ index e69de29..3b582a3 100644
+#define _GNU_SOURCE +#define _GNU_SOURCE
+#endif +#endif
+ +
+#include "config.h" /* For _FILE_OFFSET_BITS */
+
+#include <errno.h> +#include <errno.h>
+#include <pthread.h> +#include <pthread.h>
+#include <setjmp.h> +#include <setjmp.h>
@ -164,6 +166,9 @@ index e69de29..3b582a3 100644
+# ifndef constructor +# ifndef constructor
+# define constructor __constructor__ +# define constructor __constructor__
+# endif +# endif
+# ifndef packed
+# define packed __packed__
+# endif
+# ifndef inline +# ifndef inline
+# define inline __inline__ +# define inline __inline__
+# endif +# endif
@ -187,8 +192,7 @@ index e69de29..3b582a3 100644
+ int errcode; + int errcode;
+ struct stat argument; + struct stat argument;
+ stat_t function; + stat_t function;
+ char *path; +} attribute((packed)) handle_t;
+} handle_t;
+ +
+static volatile handle_t handle; +static volatile handle_t handle;
+ +
@ -205,6 +209,7 @@ index e69de29..3b582a3 100644
+static void attribute((constructor)) start(void) +static void attribute((constructor)) start(void)
+{ +{
+ sigset_t sigset, oldset; + sigset_t sigset, oldset;
+ char path[PATH_MAX];
+ handle_t handle; + handle_t handle;
+ ssize_t in; + ssize_t in;
+ +
@ -234,12 +239,10 @@ index e69de29..3b582a3 100644
+ pipes[0] = pipes[3] = -1; + pipes[0] = pipes[3] = -1;
+ +
+ while ((in = read(0, &handle, sizeof(handle_t))) == sizeof(handle_t) && + while ((in = read(0, &handle, sizeof(handle_t))) == sizeof(handle_t) &&
+ (handle.path = (char*)malloc(handle.len)) && + (in = read(0, path, handle.len)) == handle.len) {
+ (in = read(0, handle.path, handle.len)) == handle.len) { + if (handle.function(path, &handle.argument) < 0)
+ if (handle.function(handle.path, &handle.argument) < 0)
+ handle.errcode = errno; + handle.errcode = errno;
+ write(1, &handle.errcode, sizeof(handle.errcode)+sizeof(handle.argument)); + write(1, &handle.errcode, sizeof(handle.errcode)+sizeof(handle.argument));
+ free(handle.path);
+ } + }
+ sigprocmask(SIG_SETMASK, &oldset, NULL); + sigprocmask(SIG_SETMASK, &oldset, NULL);
+ exit(0); + exit(0);
@ -273,7 +276,6 @@ index e69de29..3b582a3 100644
+{ +{
+ struct sigaction old_act, new_act; + struct sigaction old_act, new_act;
+ sigset_t sigset, oldset; + sigset_t sigset, oldset;
+ handle_t handle;
+ +
+ if (active <= 0) { /* Oops, last one failed therefore clear status and restart */ + if (active <= 0) { /* Oops, last one failed therefore clear status and restart */
+ int status; + int status;
@ -282,10 +284,13 @@ index e69de29..3b582a3 100644
+ } + }
+ +
+ handle.len = strlen(path) + 1; + handle.len = strlen(path) + 1;
+ if (handle.len >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ goto error;
+ }
+ handle.errcode = 0; + handle.errcode = 0;
+ handle.argument = *argument; + handle.argument = *argument;
+ handle.function = function; + handle.function = function;
+ handle.path = (char*)0;
+ +
+ sigemptyset(&sigset); + sigemptyset(&sigset);
+ sigaddset(&sigset, SIGALRM); + sigaddset(&sigset, SIGALRM);
@ -314,8 +319,10 @@ index e69de29..3b582a3 100644
+ errno = handle.errcode; + errno = handle.errcode;
+ goto error; + goto error;
+ } + }
+
+ *argument = handle.argument; + *argument = handle.argument;
+ sigprocmask(SIG_SETMASK, &oldset, NULL); + sigprocmask(SIG_SETMASK, &oldset, NULL);
+
+ return 0; + return 0;
+timed: +timed:
+ (void) alarm(0); + (void) alarm(0);
@ -333,7 +340,7 @@ diff --git a/src/timeout.h b/src/timeout.h
index e69de29..50dd135 100644 index e69de29..50dd135 100644
--- a/src/timeout.h --- a/src/timeout.h
+++ b/src/timeout.h +++ b/src/timeout.h
@@ -0,0 +1,33 @@ @@ -0,0 +1,36 @@
+/* +/*
+ * timout.h Advanced timeout handling for file system calls + * timout.h Advanced timeout handling for file system calls
+ * to avoid deadlocks on remote file shares. + * to avoid deadlocks on remote file shares.
@ -353,9 +360,12 @@ index e69de29..50dd135 100644
+#ifndef _TIMEOUT_H +#ifndef _TIMEOUT_H
+#define _TIMEOUT_H +#define _TIMEOUT_H
+ +
+#include "config.h" /* For _FILE_OFFSET_BITS */
+
+#include <sys/types.h> +#include <sys/types.h>
+#include <sys/stat.h> +#include <sys/stat.h>
+#include <time.h> +#include <time.h>
+#include <limits.h>
+ +
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
+# ifndef restrict +# ifndef restrict

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Oct 5 09:47:38 UTC 2011 - werner@suse.de
- Handle internal size of structure stat by including config.h
to avoid size missmatch during copy result back (bnc#720882)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Oct 3 10:56:19 UTC 2011 - mmarek@suse.cz Mon Oct 3 10:56:19 UTC 2011 - mmarek@suse.cz

View File

@ -51,7 +51,7 @@ processes that are using specified files or filesystems.
%prep %prep
%setup -q %setup -q
%patch42 -p1 %patch42 -p1
#%patch43 -p1 %patch43 -p1 -b .to
%patch1 -p0 -b .tigetstr %patch1 -p0 -b .tigetstr
%patch2 -p0 -b .pstree %patch2 -p0 -b .pstree
%patch0 -p0 -b .0 %patch0 -p0 -b .0