projects
/
crypto.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added asynchronous event tasks to SILC Scheduler. Added
[crypto.git]
/
lib
/
silcutil
/
unix
/
silcunixschedule.c
diff --git
a/lib/silcutil/unix/silcunixschedule.c
b/lib/silcutil/unix/silcunixschedule.c
index 137d52def8d784e8ddd55dc69f2fd6a661fe81b2..d81cfa751668172aa9d3789a7a51c26bac0a473a 100644
(file)
--- a/
lib/silcutil/unix/silcunixschedule.c
+++ b/
lib/silcutil/unix/silcunixschedule.c
@@
-121,11
+121,13
@@
int silc_poll(SilcSchedule schedule, void *context)
struct pollfd *fds = internal->fds;
SilcUInt32 fds_count = internal->fds_count;
int fd, ret, i = 0, timeout = -1;
struct pollfd *fds = internal->fds;
SilcUInt32 fds_count = internal->fds_count;
int fd, ret, i = 0, timeout = -1;
+ void *fdp;
silc_hash_table_list(schedule->fd_queue, &htl);
silc_hash_table_list(schedule->fd_queue, &htl);
- while (silc_hash_table_get(&htl,
(void *)&fd
, (void *)&task)) {
+ while (silc_hash_table_get(&htl,
&fdp
, (void *)&task)) {
if (!task->events)
continue;
if (!task->events)
continue;
+ fd = SILC_PTR_TO_32(fdp);
/* Allocate larger fd table if needed */
if (i >= fds_count) {
/* Allocate larger fd table if needed */
if (i >= fds_count) {
@@
-198,14
+200,16
@@
int silc_select(SilcSchedule schedule, void *context)
SilcTaskFd task;
fd_set in, out;
int fd, max_fd = 0, ret;
SilcTaskFd task;
fd_set in, out;
int fd, max_fd = 0, ret;
+ void *fdp;
FD_ZERO(&in);
FD_ZERO(&out);
silc_hash_table_list(schedule->fd_queue, &htl);
FD_ZERO(&in);
FD_ZERO(&out);
silc_hash_table_list(schedule->fd_queue, &htl);
- while (silc_hash_table_get(&htl,
(void *)&fd
, (void *)&task)) {
+ while (silc_hash_table_get(&htl,
&fdp
, (void *)&task)) {
if (!task->events)
continue;
if (!task->events)
continue;
+ fd = SILC_PTR_TO_32(fdp);
#ifdef FD_SETSIZE
if (fd >= FD_SETSIZE)
#ifdef FD_SETSIZE
if (fd >= FD_SETSIZE)
@@
-233,9
+237,10
@@
int silc_select(SilcSchedule schedule, void *context)
return ret;
silc_hash_table_list(schedule->fd_queue, &htl);
return ret;
silc_hash_table_list(schedule->fd_queue, &htl);
- while (silc_hash_table_get(&htl,
(void *)&fd
, (void *)&task)) {
+ while (silc_hash_table_get(&htl,
&fdp
, (void *)&task)) {
if (!task->header.valid || !task->events)
continue;
if (!task->header.valid || !task->events)
continue;
+ fd = SILC_PTR_TO_32(fdp);
#ifdef FD_SETSIZE
if (fd >= FD_SETSIZE)
#ifdef FD_SETSIZE
if (fd >= FD_SETSIZE)
@@
-349,7
+354,7
@@
void *silc_schedule_internal_init(SilcSchedule schedule,
SilcUnixScheduler internal;
int i;
SilcUnixScheduler internal;
int i;
- internal = silc_
calloc(
1, sizeof(*internal));
+ internal = silc_
scalloc(schedule->stack,
1, sizeof(*internal));
if (!internal)
return NULL;
if (!internal)
return NULL;
@@
-389,7
+394,6
@@
void *silc_schedule_internal_init(SilcSchedule schedule,
#ifdef SILC_THREADS
if (pipe(internal->wakeup_pipe)) {
SILC_LOG_ERROR(("pipe() fails: %s", strerror(errno)));
#ifdef SILC_THREADS
if (pipe(internal->wakeup_pipe)) {
SILC_LOG_ERROR(("pipe() fails: %s", strerror(errno)));
- silc_free(internal);
return NULL;
}
return NULL;
}
@@
-433,8
+437,6
@@
void silc_schedule_internal_uninit(SilcSchedule schedule, void *context)
#elif defined(HAVE_POLL) && defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
silc_free(internal->fds);
#endif /* HAVE_POLL && HAVE_SETRLIMIT && RLIMIT_NOFILE */
#elif defined(HAVE_POLL) && defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
silc_free(internal->fds);
#endif /* HAVE_POLL && HAVE_SETRLIMIT && RLIMIT_NOFILE */
-
- silc_free(internal);
}
/* Wakes up the scheduler */
}
/* Wakes up the scheduler */
@@
-493,6
+495,7
@@
void silc_schedule_internal_signal_register(SilcSchedule schedule,
signal_call[i].sig = sig;
signal_call[i].callback = callback;
signal_call[i].context = callback_context;
signal_call[i].sig = sig;
signal_call[i].callback = callback;
signal_call[i].context = callback_context;
+ signal_call[i].schedule = schedule;
signal_call[i].call = FALSE;
signal(sig, silc_schedule_internal_sighandler);
break;
signal_call[i].call = FALSE;
signal(sig, silc_schedule_internal_sighandler);
break;
@@
-522,6
+525,7
@@
void silc_schedule_internal_signal_unregister(SilcSchedule schedule,
signal_call[i].sig = 0;
signal_call[i].callback = NULL;
signal_call[i].context = NULL;
signal_call[i].sig = 0;
signal_call[i].callback = NULL;
signal_call[i].context = NULL;
+ signal_call[i].schedule = NULL;
signal_call[i].call = FALSE;
signal(sig, SIG_DFL);
}
signal_call[i].call = FALSE;
signal(sig, SIG_DFL);
}