updates.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 21 Oct 2006 13:44:01 +0000 (13:44 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 21 Oct 2006 13:44:01 +0000 (13:44 +0000)
lib/silcutil/DIRECTORY
lib/silcutil/tests/test_silcatomic.c
lib/silcutil/tests/test_silcfdstream.c
lib/silcutil/tests/test_silcnet.c

index 3a7301aec482cd6a00b0be3965db9ae9c88aed9f..2b334d5e3a63a489de405a79962adf9ce6eedb48 100644 (file)
@@ -2,27 +2,33 @@
 @LIBRARY=SILC Utility Library
 @FILENAME=silcutillib.html
 @LINK=silctypes.html:Basic SILC Types
-@LINK=silcbuffer.html:SILC Buffer Interface
-@LINK=silcbuffmt.html:SILC Buffer Format Interface
-@LINK=silchashtable.html:SILC Hash Table Interface
-@LINK=silclog.html:SILC Logging Interface
-@LINK=silcmemory.html:SILC Memory Interface
-@LINK=silcthread.html:SILC Thread Interface
-@LINK=silcmutex.html:SILC Mutex Interface
-@LINK=silccond.html:SILC Conditional Variable Interface
-@LINK=silcatomic.html:SILC Atomic Operations Interface
-@LINK=silcnet.html:SILC Network Interface
-@LINK=silcschedule.html:SILC Schedule Interface
-@LINK=silcsockconn.html:SILC Socket Interface
-@LINK=silcprotocol.html:SILC Protocol Interface
-@LINK=silcconfig.html:SILC Config Interface
-@LINK=silcfileutil.html:SILC File Util Interface
-@LINK=silcstrutil.html:SILC String Util Interface
-@LINK=silcutf8.html:SILC UTF-8 Interface
-@LINK=silcstringprep.html:SILC Stringprep Interface
-@LINK=silcutil.html:SILC Util Interface
-@LINK=silclist.html:SILC List Interface
-@LINK=silcdlist.html:SILC Dynamic List Interface
+@LINK=silcbuffer.html:Data Buffer Interface
+@LINK=silcbuffmt.html:Data Buffer Format Interface
+@LINK=silchashtable.html:Hash Table Interface
+@LINK=silcmemory.html:Memory Allocation Interface
+@LINK=silcstack.html:Data Stack (memory pool) Interface
+@LINK=silcthread.html:Thread Interface
+@LINK=silcmutex.html:Mutual Exclusion Lock Interface
+@LINK=silccond.html:Conditional Variable Interface
+@LINK=silcatomic.html:Atomic Operations Interface
+@LINK=silcnet.html:Network (TCP and UDP) Interface
+@LINK=silcschedule.html:Scheduler Interface
+@LINK=silcsocketstream.html:Socket Stream Interface
+@LINK=silcfdstream.html:File Descriptor Stream Interface
+@LINK=silcstream.html:Abstract Stream Interface
+@LINK=silcfsm.html:Finite State Machine Interface
+@LINK=silcfileutil.html:File Utility Functions
+@LINK=silcstrutil.html:String Utility Interface
+@LINK=silcutf8.html:UTF-8 String Interface
+@LINK=silcstringprep.html:Stringprep Interface
+@LINK=silcutil.html:Utility Functions
+@LINK=silclist.html:List Interface
+@LINK=silcdlist.html:Dynamic List Interface
+@LINK=silcasync.html:Asynchronous Operation Interface
+@LINK=silcmime.html:MIME Interface
+@LINK=silctime.html:Time Utility Functions
+@LINK=silclog.html:Logging Interface
+@LINK=silcconfig.html:Config File Interface
 -->
 
 <big><b>SILC Utility Library</b></big>
index dc2bac6eaac36ce3540c7032d492f96514dd3d41..feaf2895ee2d8fb586b44aa689f0f13733c9234a 100644 (file)
@@ -39,6 +39,11 @@ int main(int argc, char **argv)
 
   SILC_LOG_DEBUG(("Current value: %d (-513)", silc_atomic_get_int(&ref)));
 
+  SILC_LOG_DEBUG(("Swapping -513 with 8739200"));
+  if (!silc_atomic_cas(&ref, silc_atomic_get_int(&ref), 8739200))
+    goto err;
+  SILC_LOG_DEBUG(("Current value: %d (8739200)", silc_atomic_get_int(&ref)));
+
   silc_atomic_uninit(&ref);
 
   success = TRUE;
index fad7a6dd670680edf647550134056148b5da9a14..e4d53a59e7316d327107c6c8a8875ded929b7f14 100644 (file)
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
   if (argc > 1 && !strcmp(argv[1], "-d")) {
     silc_log_debug(TRUE);
     silc_log_debug_hexdump(TRUE);
-    silc_log_set_debug_string("fdstream*");
+    silc_log_set_debug_string("*fdstream*");
   }
 
   SILC_LOG_DEBUG(("Allocating scheduler"));
index 19d90a04a804bfcbd2065ae00547692f049c0c78..9158585809677f3193cdc0bccf6b40c28e6077eb 100644 (file)
@@ -8,7 +8,7 @@ typedef struct {
   SilcFSM fsm;
   SilcFSMSemaStruct sema;
   SilcFSMThreadStruct thread;
-  SilcNetServer server;
+  SilcNetListener server;
   SilcStream client_stream;
   SilcNetStatus client_status;
   SilcStream server_stream;
@@ -50,7 +50,7 @@ SILC_FSM_STATE(test_st_connect)
   SILC_LOG_DEBUG(("test_st_connect"));
   SILC_LOG_DEBUG(("Connecting to server"));
 
-  silc_fsm_next(fsm, test_st_connected, NULL);
+  silc_fsm_next(fsm, test_st_connected);
   SILC_FSM_CALL(silc_net_tcp_connect(NULL, "localhost", 5000,
                                     silc_fsm_get_schedule(fsm),
                                     test_connected, f));
@@ -82,24 +82,24 @@ SILC_FSM_STATE(test_st_start)
   SILC_LOG_DEBUG(("test_st_start"));
 
   SILC_LOG_DEBUG(("Creating network listener"));
-  f->server = silc_net_create_server(NULL, 0, 5000, FALSE,
+  f->server = silc_net_tcp_create_listener(NULL, 0, 5000, TRUE, TRUE,
                                     silc_fsm_get_schedule(fsm),
                                     test_accept_connection, f);
   if (!f->server) {
     /** Creating network listener failed */
     SILC_LOG_DEBUG(("Listener creation failed"));
-    silc_fsm_next(fsm, test_st_finish, NULL);
+    silc_fsm_next(fsm, test_st_finish);
     return SILC_FSM_CONTINUE;
   }
 
   /* Create thread to connect to the listener */
   silc_fsm_thread_init(&f->thread, fsm, f, NULL, NULL, FALSE);
-  silc_fsm_start(&f->thread, test_st_connect, NULL);
+  silc_fsm_start(&f->thread, test_st_connect);
 
   /** Start waiting connection */
   SILC_LOG_DEBUG(("Start waiting for incoming connections"));
   silc_fsm_sema_init(&f->sema, fsm, 0);
-  silc_fsm_next(fsm, test_st_second, NULL);
+  silc_fsm_next(fsm, test_st_second);
   return SILC_FSM_CONTINUE;
 }
 
@@ -116,17 +116,17 @@ SILC_FSM_STATE(test_st_second)
   if (f->client_status != SILC_NET_OK) {
     /** Accepting new connection failed */
     SILC_LOG_DEBUG(("Accepting failed %d", f->client_status));
-    silc_fsm_next(fsm, test_st_finish, NULL);
+    silc_fsm_next(fsm, test_st_finish);
     return SILC_FSM_CONTINUE;
   }
 
   silc_socket_stream_get_info(f->client_stream, NULL, &host, &ip, &port);
   SILC_LOG_DEBUG(("Accepted new connection %s, %s:%d", host, ip, port));
 
-  /** Finish */
+  /** Wait thread to terminate */
   f->success = TRUE;
-  silc_fsm_next(fsm, test_st_finish, NULL);
-  return SILC_FSM_CONTINUE;
+  silc_fsm_next(fsm, test_st_finish);
+  SILC_FSM_THREAD_WAIT(&f->thread);
 }
 
 SILC_FSM_STATE(test_st_finish)
@@ -145,7 +145,7 @@ SILC_FSM_STATE(test_st_finish)
   }
 
   SILC_LOG_DEBUG(("Closing network listener"));
-  silc_net_close_server(f->server);
+  silc_net_close_listener(f->server);
 
   SILC_LOG_DEBUG(("Finish machine"));
   return SILC_FSM_FINISH;
@@ -182,7 +182,7 @@ int main(int argc, char **argv)
   fsm = silc_fsm_alloc(f, destructor, NULL, schedule);
   if (!fsm)
     goto err;
-  silc_fsm_start(fsm, test_st_start, NULL);
+  silc_fsm_start(fsm, test_st_start);
   f->fsm = fsm;
 
   SILC_LOG_DEBUG(("Running scheduler"));