projects
/
silc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
af6a141
)
Internal scheduler initialization cannot return NULL anymore.
author
Pekka Riikonen
<priikone@silcnet.org>
Fri, 16 Feb 2007 14:38:47 +0000
(14:38 +0000)
committer
Pekka Riikonen
<priikone@silcnet.org>
Fri, 16 Feb 2007 14:38:47 +0000
(14:38 +0000)
lib/silcutil/silcschedule.c
patch
|
blob
|
history
lib/silcutil/silcschedule_i.h
patch
|
blob
|
history
lib/silcutil/stacktrace.c
patch
|
blob
|
history
lib/silcutil/symbian/silcsymbianscheduler.cpp
patch
|
blob
|
history
lib/silcutil/unix/silcunixnet.c
patch
|
blob
|
history
lib/silcutil/unix/silcunixschedule.c
patch
|
blob
|
history
lib/silcutil/win32/silcwin32schedule.c
patch
|
blob
|
history
diff --git
a/lib/silcutil/silcschedule.c
b/lib/silcutil/silcschedule.c
index adfacd55ea9eb04ca171ee0e001c151a3ad60124..7ffcc51088be6edb0b1f22cd0d60a4b9d13f10d0 100644
(file)
--- a/
lib/silcutil/silcschedule.c
+++ b/
lib/silcutil/silcschedule.c
@@
-325,8
+325,10
@@
SilcSchedule silc_schedule_init(int max_tasks, void *app_context)
schedule->fd_queue =
silc_hash_table_alloc(0, silc_hash_uint, NULL, NULL, NULL,
silc_schedule_fd_destructor, NULL, TRUE);
schedule->fd_queue =
silc_hash_table_alloc(0, silc_hash_uint, NULL, NULL, NULL,
silc_schedule_fd_destructor, NULL, TRUE);
- if (!schedule->fd_queue)
+ if (!schedule->fd_queue) {
+ silc_free(schedule);
return NULL;
return NULL;
+ }
silc_list_init(schedule->timeout_queue, struct SilcTaskStruct, next);
silc_list_init(schedule->free_tasks, struct SilcTaskStruct, next);
silc_list_init(schedule->timeout_queue, struct SilcTaskStruct, next);
silc_list_init(schedule->free_tasks, struct SilcTaskStruct, next);
@@
-340,6
+342,12
@@
SilcSchedule silc_schedule_init(int max_tasks, void *app_context)
/* Initialize the platform specific scheduler. */
schedule->internal = schedule_ops.init(schedule, app_context);
/* Initialize the platform specific scheduler. */
schedule->internal = schedule_ops.init(schedule, app_context);
+ if (!schedule->internal) {
+ silc_hash_table_free(schedule->fd_queue);
+ silc_mutex_free(schedule->lock);
+ silc_free(schedule);
+ return NULL;
+ }
/* Timeout freelist garbage collection */
silc_schedule_task_add_timeout(schedule, silc_schedule_timeout_gc,
/* Timeout freelist garbage collection */
silc_schedule_task_add_timeout(schedule, silc_schedule_timeout_gc,
diff --git
a/lib/silcutil/silcschedule_i.h
b/lib/silcutil/silcschedule_i.h
index 04976c36dbe1e7ee9f1bcd3571cb4b9930ed53db..fcb47aa48bd8863b92237b8892971c6cd675bee7 100644
(file)
--- a/
lib/silcutil/silcschedule_i.h
+++ b/
lib/silcutil/silcschedule_i.h
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 200
6
Pekka Riikonen
+ Copyright (C) 2001 - 200
7
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-86,7
+86,8
@@
typedef struct {
/* Initializes the platform specific scheduler. This for example initializes
the wakeup mechanism of the scheduler. In multi-threaded environment
the scheduler needs to be wakenup when tasks are added or removed from
/* Initializes the platform specific scheduler. This for example initializes
the wakeup mechanism of the scheduler. In multi-threaded environment
the scheduler needs to be wakenup when tasks are added or removed from
- the task queues. Returns context to the platform specific scheduler. */
+ the task queues. Returns context to the platform specific scheduler.
+ If this returns NULL the scheduler initialization will fail. */
void *(*init)(SilcSchedule schedule, void *app_context);
/* Uninitializes the platform specific scheduler context. */
void *(*init)(SilcSchedule schedule, void *app_context);
/* Uninitializes the platform specific scheduler context. */
diff --git
a/lib/silcutil/stacktrace.c
b/lib/silcutil/stacktrace.c
index 1a93192647fb7623deba80a6d136677701cbc05a..2174080cf867202275fae67a9613cf26c3ad6883 100644
(file)
--- a/
lib/silcutil/stacktrace.c
+++ b/
lib/silcutil/stacktrace.c
@@
-203,7
+203,7
@@
void silc_st_dump(void)
fprintf(fp, "<stacktrace>%s:%d: #blocks=%lu, bytes=%lu\n",
stack->file, stack->line, blocks, bytes);
for (i = 0; i < stack->depth; i++)
fprintf(fp, "<stacktrace>%s:%d: #blocks=%lu, bytes=%lu\n",
stack->file, stack->line, blocks, bytes);
for (i = 0; i < stack->depth; i++)
- fprintf(fp, "
<pc>
%p\n", stack->stack[i]);
+ fprintf(fp, "
\tpc=
%p\n", stack->stack[i]);
}
}
}
}
diff --git
a/lib/silcutil/symbian/silcsymbianscheduler.cpp
b/lib/silcutil/symbian/silcsymbianscheduler.cpp
index bf3ee235e0f6811afe0014c6b3b6c0dcc9a1b2ce..d8a8a1836327efbd6f8dd3f044a309c6bf2a425f 100644
(file)
--- a/
lib/silcutil/symbian/silcsymbianscheduler.cpp
+++ b/
lib/silcutil/symbian/silcsymbianscheduler.cpp
@@
-4,7
+4,7
@@
\r
Author: Pekka Riikonen <priikone@silcnet.org>
\r
\r
\r
Author: Pekka Riikonen <priikone@silcnet.org>
\r
\r
- Copyright (C) 1998 - 200
6
Pekka Riikonen
\r
+ Copyright (C) 1998 - 200
7
Pekka Riikonen
\r
\r
This program is free software; you can redistribute it and/or modify
\r
it under the terms of the GNU General Public License as published by
\r
\r
This program is free software; you can redistribute it and/or modify
\r
it under the terms of the GNU General Public License as published by
\r
@@
-48,7
+48,7
@@
void *silc_schedule_internal_init(SilcSchedule schedule,
void *app_context)
\r
{
\r
/* Nothing to do */
\r
void *app_context)
\r
{
\r
/* Nothing to do */
\r
- return
NULL
;
\r
+ return
(void *)1
;
\r
}
\r
\r
\r
}
\r
\r
\r
diff --git
a/lib/silcutil/unix/silcunixnet.c
b/lib/silcutil/unix/silcunixnet.c
index ba1736ddee769a219d94ead785bbb0f0c7925760..4254fab98c0b6c171e7cb0679c6d30eec55aadc4 100644
(file)
--- a/
lib/silcutil/unix/silcunixnet.c
+++ b/
lib/silcutil/unix/silcunixnet.c
@@
-641,6
+641,8
@@
SILC_FSM_STATE(silc_net_connect_st_connected)
return SILC_FSM_CONTINUE;
}
return SILC_FSM_CONTINUE;
}
+ SILC_LOG_DEBUG(("TCP connection established"));
+
/** Connection created */
silc_fsm_next(fsm, silc_net_connect_st_stream);
SILC_FSM_CALL((conn->sop = silc_socket_tcp_stream_create(
/** Connection created */
silc_fsm_next(fsm, silc_net_connect_st_stream);
SILC_FSM_CALL((conn->sop = silc_socket_tcp_stream_create(
diff --git
a/lib/silcutil/unix/silcunixschedule.c
b/lib/silcutil/unix/silcunixschedule.c
index df080730f30cfc48965b8a972c87f0891c8ae266..9a4ae9a49a192c1f507055bed2d9d443773d7a6c 100644
(file)
--- a/
lib/silcutil/unix/silcunixschedule.c
+++ b/
lib/silcutil/unix/silcunixschedule.c
@@
-338,8
+338,10
@@
void *silc_schedule_internal_init(SilcSchedule schedule,
#if defined(HAVE_EPOLL_WAIT)
internal->epfd = epoll_create(4);
#if defined(HAVE_EPOLL_WAIT)
internal->epfd = epoll_create(4);
- if (internal->epfd < 0)
+ if (internal->epfd < 0) {
+ SILC_LOG_ERROR(("epoll_create() failed: %s", strerror(errno)));
return NULL;
return NULL;
+ }
internal->fds = silc_calloc(4, sizeof(*internal->fds));
if (!internal->fds) {
close(internal->epfd);
internal->fds = silc_calloc(4, sizeof(*internal->fds));
if (!internal->fds) {
close(internal->epfd);
diff --git
a/lib/silcutil/win32/silcwin32schedule.c
b/lib/silcutil/win32/silcwin32schedule.c
index f4a263fcbd4d712df36479066f893c75b401b568..aa2cd2542fd7d5545c8520e96ee69a8aaac1aa0d 100644
(file)
--- a/
lib/silcutil/win32/silcwin32schedule.c
+++ b/
lib/silcutil/win32/silcwin32schedule.c
@@
-242,7
+242,7
@@
void *silc_schedule_internal_init(SilcSchedule schedule, void *app_context)
return (void *)wakeup;
#else
return (void *)wakeup;
#else
- return
NULL
;
+ return
(void *)1
;
#endif
}
#endif
}