Added SILC Thread Queue API
[crypto.git] / lib / silcserver / server.c
index 756030e0e89a851e8d52868d01e60436b7b08be6..27609a5a4dce3aa71733a086398047fabb455330 100644 (file)
@@ -80,7 +80,7 @@ static SilcBool silc_server_packet_receive(SilcPacketEngine engine,
   /* Signal thread that packet has arrived */
   if (!thread->new_packet) {
     thread->new_packet = TRUE;
-    SILC_FSM_SEMA_POST(&thread->wait_event);
+    SILC_FSM_EVENT_SIGNAL(&thread->wait_event);
   }
 
   return TRUE;
@@ -190,7 +190,7 @@ static void silc_server_accept_connection(SilcNetStatus status,
   /* Signal server of new connection */
   if (!server->new_connection) {
     server->new_connection = TRUE;
-    SILC_FSM_SEMA_POST(&server->wait_event);
+    SILC_FSM_EVENT_SIGNAL(&server->wait_event);
   }
 }
 
@@ -216,11 +216,11 @@ SILC_FSM_STATE(silc_server_thread_st_start)
 
   /*** Run thread's machine */
   silc_fsm_init(&thread->fsm, thread, NULL, NULL, silc_fsm_get_schedule(fsm));
-  silc_fsm_sema_init(&thread->wait_event, &thread->fsm, 0);
+  silc_fsm_event_init(&thread->wait_event, &thread->fsm, 0);
   silc_fsm_start_sync(&thread->fsm, silc_server_thread_st_run);
 
   /* Signal server that we are up */
-  SILC_FSM_SEMA_POST(&thread->server->thread_up);
+  SILC_FSM_EVENT_SIGNAL(&thread->server->thread_up);
 
   /* Wait here for this thread to finish */
   return SILC_FSM_WAIT;
@@ -235,7 +235,7 @@ SILC_FSM_STATE(silc_server_thread_st_run)
   SILC_LOG_DEBUG(("Start"));
 
   /* Wait for events */
-  SILC_FSM_SEMA_WAIT(&thread->wait_event);
+  SILC_FSM_EVENT_WAIT(&thread->wait_event);
 
   /* Process events */
 
@@ -310,7 +310,7 @@ SILC_FSM_STATE(silc_server_st_run)
   SILC_LOG_DEBUG(("Start"));
 
   /* Wait for events */
-  SILC_FSM_SEMA_WAIT(&server->wait_event);
+  SILC_FSM_EVENT_WAIT(&server->wait_event);
 
   /* Process events */
 
@@ -406,7 +406,7 @@ SILC_FSM_STATE(silc_server_st_new_connection)
     /* Signal the thread for new connection */
     if (!thread->new_connection) {
       thread->new_connection = TRUE;
-      SILC_FSM_SEMA_POST(&thread->wait_event);
+      SILC_FSM_EVENT_SIGNAL(&thread->wait_event);
     }
     silc_mutex_unlock(server->lock);
   }
@@ -425,7 +425,7 @@ SILC_FSM_STATE(silc_server_st_wait_new_thread)
   SilcServer server = fsm_context;
 
   /* Wait here until new thread is up */
-  SILC_FSM_SEMA_WAIT(&server->thread_up);
+  SILC_FSM_EVENT_WAIT(&server->thread_up);
 
   /** Process new connections */
   silc_fsm_next(fsm, silc_server_st_new_connection);
@@ -592,8 +592,8 @@ SilcServer silc_server_alloc(void *app_context, SilcServerParams params,
   silc_fsm_init(&server->fsm, server, silc_server_destructor, NULL, schedule);
 
   /* Init semaphore signallers */
-  silc_fsm_sema_init(&server->wait_event, &server->fsm, 0);
-  silc_fsm_sema_init(&server->thread_up, &server->fsm, 0);
+  silc_fsm_event_init(&server->wait_event, &server->fsm, 0);
+  silc_fsm_event_init(&server->thread_up, &server->fsm, 0);
 
   /* Initialize lists */
   silc_list_init(server->new_conns, struct SilcServerAcceptStruct, next);
@@ -853,16 +853,16 @@ void silc_server_run(SilcServer server, SilcServerRunning running,
 
   /* Signal the application when we are running */
   server->run_callback = TRUE;
-  SILC_FSM_SEMA_POST(&server->wait_event);
+  SILC_FSM_EVENT_SIGNAL(&server->wait_event);
 
   /* Signal to connect to router */
   server->connect_router = TRUE;
-  SILC_FSM_SEMA_POST(&server->wait_event);
+  SILC_FSM_EVENT_SIGNAL(&server->wait_event);
 
   /* Start getting statistics from the network on normal server */
   if (server->server_type != SILC_ROUTER) {
     server->get_statistics = TRUE;
-    SILC_FSM_SEMA_POST(&server->wait_event);
+    SILC_FSM_EVENT_SIGNAL(&server->wait_event);
   }
 }
 
@@ -878,7 +878,7 @@ void silc_server_stop(SilcServer server, SilcServerStop stopped,
 
   /* Signal that server is going down */
   server->server_shutdown = TRUE;
-  SILC_FSM_SEMA_POST(&server->wait_event);
+  SILC_FSM_EVENT_SIGNAL(&server->wait_event);
 }
 
 /* Disconnects remote connection */