aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2011-11-07 20:09:06 +0100
committerBenoit Germain <bnt.germain@gmail.com>2011-11-07 20:09:06 +0100
commitfb4b7acae4bdacd6c0f669591956281011bc0068 (patch)
tree6b6b94da4dba678ace69256e8400c1e71ca84956 /src/lanes.c
parent053f7cff3c95acb915e6babfd306971f11bb7986 (diff)
downloadlanes-fb4b7acae4bdacd6c0f669591956281011bc0068.tar.gz
lanes-fb4b7acae4bdacd6c0f669591956281011bc0068.tar.bz2
lanes-fb4b7acae4bdacd6c0f669591956281011bc0068.zip
* fix all compilation warnings raised by -Wextra
* fix a multithreading issue at desinit causing invalid memory accesses (to be verified)
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lanes.c b/src/lanes.c
index 44db625..1ebe91d 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -296,7 +296,7 @@ LUAG_FUNC( linda_send)
296 check_key_types( L, key_i, key_i); 296 check_key_types( L, key_i, key_i);
297 297
298 // make sure there is something to send 298 // make sure there is something to send
299 if( lua_gettop( L) == key_i) 299 if( (uint_t)lua_gettop( L) == key_i)
300 { 300 {
301 luaL_error( L, "no data to send"); 301 luaL_error( L, "no data to send");
302 } 302 }
@@ -994,8 +994,9 @@ static void selfdestruct_add( struct s_lane *s ) {
994/* 994/*
995* A free-running lane has ended; remove it from selfdestruct chain 995* A free-running lane has ended; remove it from selfdestruct chain
996*/ 996*/
997static void selfdestruct_remove( struct s_lane *s ) { 997static bool_t selfdestruct_remove( struct s_lane *s )
998 998{
999 bool_t found = FALSE;
999 MUTEX_LOCK( &selfdestruct_cs ); 1000 MUTEX_LOCK( &selfdestruct_cs );
1000 { 1001 {
1001 // Make sure (within the MUTEX) that we actually are in the chain 1002 // Make sure (within the MUTEX) that we actually are in the chain
@@ -1004,7 +1005,6 @@ static void selfdestruct_remove( struct s_lane *s ) {
1004 // 1005 //
1005 if (s->selfdestruct_next != NULL) { 1006 if (s->selfdestruct_next != NULL) {
1006 struct s_lane **ref= (struct s_lane **) &selfdestruct_first; 1007 struct s_lane **ref= (struct s_lane **) &selfdestruct_first;
1007 bool_t found= FALSE;
1008 1008
1009 while( *ref != SELFDESTRUCT_END ) { 1009 while( *ref != SELFDESTRUCT_END ) {
1010 if (*ref == s) { 1010 if (*ref == s) {
@@ -1019,6 +1019,7 @@ static void selfdestruct_remove( struct s_lane *s ) {
1019 } 1019 }
1020 } 1020 }
1021 MUTEX_UNLOCK( &selfdestruct_cs ); 1021 MUTEX_UNLOCK( &selfdestruct_cs );
1022 return found;
1022} 1023}
1023 1024
1024// Initialized by 'init_once_LOCKED()': the deep userdata Linda object 1025// Initialized by 'init_once_LOCKED()': the deep userdata Linda object
@@ -1031,6 +1032,7 @@ volatile DEEP_PRELUDE *timer_deep; // = NULL
1031*/ 1032*/
1032static int selfdestruct_atexit( lua_State *L) 1033static int selfdestruct_atexit( lua_State *L)
1033{ 1034{
1035 (void)L; // unused
1034 if (selfdestruct_first == SELFDESTRUCT_END) return 0; // no free-running threads 1036 if (selfdestruct_first == SELFDESTRUCT_END) return 0; // no free-running threads
1035 1037
1036 // Signal _all_ still running threads to exit (including the timer thread) 1038 // Signal _all_ still running threads to exit (including the timer thread)
@@ -1466,7 +1468,8 @@ LUAG_FUNC( set_debug_threadname)
1466 lua_newtable(L); 1468 lua_newtable(L);
1467 } 1469 }
1468 s->waiting_on = NULL; // just in case 1470 s->waiting_on = NULL; // just in case
1469 if (s->selfdestruct_next != NULL) { 1471 if( selfdestruct_remove( s)) // check and remove (under lock!)
1472 {
1470 // We're a free-running thread and no-one's there to clean us up. 1473 // We're a free-running thread and no-one's there to clean us up.
1471 // 1474 //
1472 lua_close( s->L ); 1475 lua_close( s->L );
@@ -1476,7 +1479,6 @@ LUAG_FUNC( set_debug_threadname)
1476 SIGNAL_FREE( &s->done_signal_ ); 1479 SIGNAL_FREE( &s->done_signal_ );
1477 MUTEX_FREE( &s->done_lock_ ); 1480 MUTEX_FREE( &s->done_lock_ );
1478 #endif 1481 #endif
1479 selfdestruct_remove(s); // away from selfdestruct chain
1480 free(s); 1482 free(s);
1481 1483
1482 } else { 1484 } else {
@@ -2201,7 +2203,7 @@ LUAG_FUNC( now_secs )
2201LUAG_FUNC( wakeup_conv ) 2203LUAG_FUNC( wakeup_conv )
2202{ 2204{
2203 int year, month, day, hour, min, sec, isdst; 2205 int year, month, day, hour, min, sec, isdst;
2204 struct tm tm= {0}; 2206 struct tm t = {0,0,0,0,0,0,0,0,0};
2205 // 2207 //
2206 // .year (four digits) 2208 // .year (four digits)
2207 // .month (1..12) 2209 // .month (1..12)
@@ -2228,15 +2230,15 @@ LUAG_FUNC( wakeup_conv )
2228 lua_pop(L,1); 2230 lua_pop(L,1);
2229 STACK_END(L,0) 2231 STACK_END(L,0)
2230 2232
2231 tm.tm_year= year-1900; 2233 t.tm_year= year-1900;
2232 tm.tm_mon= month-1; // 0..11 2234 t.tm_mon= month-1; // 0..11
2233 tm.tm_mday= day; // 1..31 2235 t.tm_mday= day; // 1..31
2234 tm.tm_hour= hour; // 0..23 2236 t.tm_hour= hour; // 0..23
2235 tm.tm_min= min; // 0..59 2237 t.tm_min= min; // 0..59
2236 tm.tm_sec= sec; // 0..60 2238 t.tm_sec= sec; // 0..60
2237 tm.tm_isdst= isdst; // 0/1/negative 2239 t.tm_isdst= isdst; // 0/1/negative
2238 2240
2239 lua_pushnumber( L, (double) mktime( &tm ) ); // ms=0 2241 lua_pushnumber( L, (double) mktime( &t)); // ms=0
2240 return 1; 2242 return 1;
2241} 2243}
2242 2244