+Tue Nov 7 18:04:36 EET 2006 Pekka Riikonen <priikone@silcnet.org
+
+ * Added silc_string_split to lib/silcutil/silcstrutil.[ch].
+
+ * Added silc_mutex_assert_locked to lib/silcutil/silcmutex.h.
+
+ * silc_fsm_continue[_sync] now cancels erlier timeout set with
+ silc_fsm_next_later. Affected file lib/silcutil/silcfsm.c.
+
Sat Nov 4 21:50:37 EET 2006 Pekka Riikonen <priikone@silcnet.org
* Added SILC_STR_FUNC to buffer format API. Affected files
void *cb_context;
T threads[NUM_THREADS];
T threads2[NUM_THREADS];
+ int c;
};
SILC_FSM_STATE(test_st_start);
SILC_FSM_STATE(test_st_second);
+SILC_FSM_STATE(test_st_second_timeout);
SILC_FSM_STATE(test_st_third);
SILC_FSM_STATE(test_st_fourth);
SILC_FSM_STATE(test_st_fifth);
{
SILC_LOG_DEBUG(("test_st_second"));
- /** Move to third state, timeout */
+ /** Move to second timeout state, timeout */
SILC_LOG_DEBUG(("Move to next state with 2 second timeout"));
- silc_fsm_next_later(fsm, test_st_third, 2, 0);
+ silc_fsm_next_later(fsm, test_st_second_timeout, 2, 0);
+ return SILC_FSM_WAIT;
+}
+
+SILC_TASK_CALLBACK(test_second_timeout)
+{
+ Foo f = context;
+ SILC_LOG_DEBUG(("test_second_timeout"));
+
+ SILC_LOG_DEBUG(("Interrupt 3 second wait and continue immediately"));
+ f->c++;
+ silc_fsm_next(f->fsm, test_st_third);
+ silc_fsm_continue(f->fsm);
+}
+
+SILC_FSM_STATE(test_st_second_timeout)
+{
+ Foo f = fsm_context;
+
+ SILC_LOG_DEBUG(("test_st_second_timeout"));
+
+ /** Move to third state, timeout */
+ SILC_LOG_DEBUG(("Move to next state with 3 second timeout"));
+ SILC_LOG_DEBUG(("The timeout will be interrupted with silc_fsm_continue"));
+ silc_fsm_next_later(fsm, test_st_third, 3, 0);
+ silc_schedule_task_add_timeout(silc_fsm_get_schedule(fsm),
+ test_second_timeout, f, 2, 500000);
return SILC_FSM_WAIT;
}
SILC_LOG_DEBUG(("test_st_third"));
+ f->c++;
+ assert(f->c == 2);
+
f->fsm = fsm;
/** Wait async callback*/
f->schedule = schedule;
SILC_LOG_DEBUG(("Allocating FSM context"));
- fsm = silc_fsm_alloc(f, destructor, f, schedule);
+ f->fsm = fsm = silc_fsm_alloc(f, destructor, f, schedule);
if (!fsm)
goto err;
silc_fsm_start(fsm, test_st_start);
/* UTF-8 decoding tests */
+/* Other string util tests too */
#include "silc.h"
silc_free(s3);
silc_free(s4);
+ /* Regex test */
+ SILC_LOG_DEBUG(("Simple regex test"));
+ s1 = "foo,bar,silc,com";
+ SILC_LOG_DEBUG(("Find 'silc' from %s", s1));
+ if (!silc_string_match(s1, "silc"))
+ goto err;
+ SILC_LOG_DEBUG(("Regex match"));
+ SILC_LOG_DEBUG(("Find 'foobar' from %s", s1));
+ if (silc_string_match(s1, "foobar"))
+ goto err;
+ SILC_LOG_DEBUG(("Regex not found (Ok)"));
+
success = TRUE;
err: