Patch 2/5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch 2/5

Lino Sanfilippo



This patch enables behaviour compatible with BSD signal semantics by
making the read() calls
on the dazukofs devices restartable across signals.



Geschäftsführender Gesellschafter: Tjark Auerbach
Sitz der Gesellschaft: Tettnang
Handelsregister: Amtsgericht Ulm, HRB 630992
ALLGEMEINE GESCHÄFTSBEDINGUNGEN
Es gelten unsere Allgemeinen Geschäftsbedingungen
(AGB). Sie finden sie in der jeweils gültigen Fassung
im Internet unter http://www.avira.de/agb
***************************************************

diff -Nurp dazukofs-3.1.3-patch1/group_dev.c dazukofs-3.1.3-patch2/group_dev.c
--- dazukofs-3.1.3-patch1/group_dev.c 2010-05-30 12:58:12.000000000 +0200
+++ dazukofs-3.1.3-patch2/group_dev.c 2010-07-06 17:20:55.000000000 +0200
@@ -66,9 +66,7 @@ static ssize_t dazukofs_group_read(int g
  err = dazukofs_get_event(group_id, &event_id, &fd, &pid);
  if (err) {
  /* convert some errors to acceptable read(2) errno values */
- if (err == -ERESTARTSYS)
- return -EINTR;
- else if (err == -ENFILE)
+ if (err == -ENFILE)
  return -EIO;
  return err;
  }
@@ -125,8 +123,6 @@ static ssize_t dazukofs_group_write(int
  if (ret == 0) {
  *pos += length;
  ret = length;
- } else if (ret == -ERESTARTSYS) {
- ret = -EINTR;
  }
 
  return ret;
diff -Nurp dazukofs-3.1.3-patch1/test/showfiles.c dazukofs-3.1.3-patch2/test/showfiles.c
--- dazukofs-3.1.3-patch1/test/showfiles.c 2008-10-25 00:08:30.000000000 +0200
+++ dazukofs-3.1.3-patch2/test/showfiles.c 2010-07-06 17:27:01.000000000 +0200
@@ -25,7 +25,7 @@
 #include <errno.h>
 #include <signal.h>
 
-static int running = 1;
+static volatile sig_atomic_t running = 1;
 
 static void print_access(struct dazukofs_access *acc)
 {
@@ -48,12 +48,24 @@ static void sigterm(int sig)
 
 int main(void)
 {
+        struct sigaction sa;
  dazukofs_handle_t hndl;
  struct dazukofs_access acc;
 
- signal(SIGHUP, sigterm);
- signal(SIGINT, sigterm);
- signal(SIGTERM, sigterm);
+        memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = sigterm;
+ if (sigaction(SIGHUP, &sa, NULL)) {
+ perror("install SIGHUP handler");
+ return -1;
+ }
+ if (sigaction(SIGINT, &sa, NULL)) {
+ perror("install SIGINT handler");
+ return -1;
+ }
+ if (sigaction(SIGTERM, &sa, NULL)) {
+ perror("install SIGTERM handler");
+ return -1;
+ }
 
  hndl = dazukofs_open("dazukofs_example", DAZUKOFS_TRACK_GROUP);
  if (!hndl) {

_______________________________________________
Dazuko-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/dazuko-devel
Reply | Threaded
Open this post in threaded view
|

Re: Patch 2/5

John Ogness-10
On 2010-07-08, Lino Sanfilippo <[hidden email]> wrote:
> This patch enables behaviour compatible with BSD signal semantics by
> making the read() calls on the dazukofs devices restartable across
> signals.

It is not clear to me that this is proper behavior for read() return
values. I have decided not to apply this patch for 3.1.4-rc1.

John Ogness

--
Dazuko Maintainer

_______________________________________________
Dazuko-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/dazuko-devel
Reply | Threaded
Open this post in threaded view
|

Re: Patch 2/5

Lino Sanfilippo
John Ogness wrote:

> On 2010-07-08, Lino Sanfilippo <[hidden email]> wrote:
>  
>> This patch enables behaviour compatible with BSD signal semantics by
>> making the read() calls on the dazukofs devices restartable across
>> signals.
>>    
>
> It is not clear to me that this is proper behavior for read() return
> values. I have decided not to apply this patch for 3.1.4-rc1.
>
> John Ogness
>  
Hi,

Userspace will (in most cases) still see -EINTR if interrupted by a
signal (in fact
-ERESTARTSYS should never be seen by userspace).
The exception is if a signal handler has been installed with the
SA_RESTART flag
set, the kernel will try to restart the interrupted system call (read()
from dazukofs
device in our case) and not notify userspace.
This is a feature that has been introduced by BSD and is also supported
by Linux.
I thought it would be nice if dazukofs would support those semantics,
too (i know
some device drivers do, but I dont think its something a device _has_ to
support...)

Regards,
Lino


Geschäftsführender Gesellschafter: Tjark Auerbach
Sitz der Gesellschaft: Tettnang
Handelsregister: Amtsgericht Ulm, HRB 630992
ALLGEMEINE GESCHÄFTSBEDINGUNGEN
Es gelten unsere Allgemeinen Geschäftsbedingungen
(AGB). Sie finden sie in der jeweils gültigen Fassung
im Internet unter http://www.avira.com/de/standard-terms-conditions-business-de
***************************************************

_______________________________________________
Dazuko-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/dazuko-devel
Reply | Threaded
Open this post in threaded view
|

Re: Patch 2/5

John Ogness-10
On 2010-10-28, Lino Sanfilippo <[hidden email]> wrote:
>>> This patch enables behaviour compatible with BSD signal semantics
>>> by making the read() calls on the dazukofs devices restartable
>>> across signals.
>
a> Userspace will (in most cases) still see -EINTR if interrupted by a
> signal (in fact -ERESTARTSYS should never be seen by userspace).
> The exception is if a signal handler has been installed with the
> SA_RESTART flag set, the kernel will try to restart the interrupted
> system call (read() from dazukofs device in our case) and not notify
> userspace.  This is a feature that has been introduced by BSD and is
> also supported by Linux.  I thought it would be nice if dazukofs
> would support those semantics, too (i know some device drivers do,
> but I dont think its something a device _has_ to support...)

Thank you for the explanation. I wasn't sure because I couldn't find
the Linux code that shows how this was being handled. (But I must
admit that I did not look very hard.) I will include the patch for the
next release candidate.

John Ogness

_______________________________________________
Dazuko-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/dazuko-devel