Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : embrace
Dir : misc/embrace/src/plugins/maildir
Modified Files:
maildir.c
Log Message:
Use Ecore's realtime signal events instead of our own (buggy) signal code
===================================================================
RCS file: /cvsroot/enlightenment/misc/embrace/src/plugins/maildir/maildir.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- maildir.c 31 Mar 2004 18:28:47 -0000 1.3
+++ maildir.c 4 Apr 2004 20:19:30 -0000 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: maildir.c,v 1.3 2004/03/31 18:28:47 tsauerbeck Exp $
+ * $Id: maildir.c,v 1.4 2004/04/04 20:19:30 tsauerbeck Exp $
*
* Copyright (C) 2004 Embrace project.
*
@@ -29,24 +29,23 @@
#ifdef __linux__
# define USE_DNOTIFY
+# include <fcntl.h>
#else
# error Linux 2.4+ is required at the moment (yeah, this sucks)
#endif
-#ifdef USE_DNOTIFY
-# include <fcntl.h>
-# include <signal.h>
-#endif
-
#include <embrace_plugin.h>
#ifdef USE_DNOTIFY
typedef struct {
MailBox *mailbox;
int fd;
+ int signal;
bool is_unseen;
} NotifyData;
+static Evas_List *find_notify_data (MailBox *mb, int signal);
+
static Evas_List *notify_data = NULL;
#endif
@@ -109,22 +108,23 @@
}
#ifdef USE_DNOTIFY
-static void on_notify (int sig, siginfo_t *si, void *whatever)
+static int on_notify (void *udata, int type, void *event)
{
+ Ecore_Event_Signal_Realtime *ev = event;
NotifyData *data = NULL;
char *path;
Evas_List *l;
int num;
/* find the set we need to work with */
- for (l = notify_data; l; l = l->next) {
- data = l->data;
+ if (!(l = find_notify_data (NULL, ev->num + SIGRTMIN)))
+ return 1;
- if (si->si_fd == data->fd)
- break;
- }
+ data = l->data;
+ assert (data);
assert (data->mailbox);
+ assert (data->fd == ev->data.si_fd);
if (data->is_unseen)
path = mailbox_property_get (data->mailbox, "path_new");
@@ -141,46 +141,40 @@
num += mailbox_unseen_get (data->mailbox);
mailbox_total_set (data->mailbox, num);
}
+
+ return 0;
}
static bool monitor_dir (MailBox *mb, const char *path, bool is_unseen)
{
NotifyData *data;
- struct sigaction act;
- int fd, signal;
+ int fd;
assert (mb);
assert (path);
- signal = embrace_signal_get ();
-
- /* setup the signal handler */
- act.sa_sigaction = on_notify;
- sigemptyset (&act.sa_mask);
- act.sa_flags = SA_SIGINFO;
- sigaction (signal, &act, NULL);
-
fd = open (path, O_RDONLY);
if (fd == -1)
return false;
- /* tell the kernel what events we are interested in */
- fcntl (fd, F_SETSIG, signal);
- fcntl (fd, F_NOTIFY,
- DN_MODIFY | DN_CREATE | DN_DELETE | DN_MULTISHOT);
-
/* now store additional data so we can access it from within
* the signal handler.
*/
data = malloc (sizeof (NotifyData));
data->fd = fd;
+ data->signal = embrace_signal_get ();
data->is_unseen = is_unseen;
data->mailbox = mb;
notify_data = evas_list_append (notify_data, data);
+ /* tell the kernel what events we are interested in */
+ fcntl (fd, F_SETSIG, data->signal);
+ fcntl (fd, F_NOTIFY,
+ DN_MODIFY | DN_CREATE | DN_DELETE | DN_MULTISHOT);
+
return true;
}
@@ -199,7 +193,7 @@
return true;
}
-static Evas_List *find_notify_data (MailBox *mb)
+static Evas_List *find_notify_data (MailBox *mb, int signal)
{
NotifyData *data;
Evas_List *l;
@@ -207,7 +201,7 @@
for (l = notify_data; l; l = l->next) {
data = l->data;
- if (data->mailbox == mb)
+ if (data->mailbox == mb || data->signal == signal)
return l;
}
@@ -229,7 +223,7 @@
free (mailbox_property_get (mb, "path_new"));
#ifdef USE_DNOTIFY
- while ((l = find_notify_data (mb))) {
+ while ((l = find_notify_data (mb, 0))) {
data = l->data;
close (data->fd);
@@ -295,5 +289,10 @@
ep->remove_mailbox = maildir_remove_mailbox;
+#ifdef USE_DNOTIFY
+ ecore_event_handler_add (ECORE_EVENT_SIGNAL_REALTIME,
+ on_notify, NULL);
+#endif
+
return true;
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs