Index: /trunk/include/cf_log.h
===================================================================
--- /trunk/include/cf_log.h	(revision 37)
+++ /trunk/include/cf_log.h	(revision 38)
@@ -30,5 +30,6 @@
 #define CF_LOG_BUFFER_DEFAULT			-1
 
-/** 로그 기록 시 버퍼를 사용하지 않고 즉시 기록
+/**
+ * 로그 기록 시 버퍼를 사용하지 않고 즉시 기록
  *
  * @see CF_Log_CreateCtx, CF_LOG_OPEN, CF_Log_Initialize
Index: /trunk/src/cf_log.c
===================================================================
--- /trunk/src/cf_log.c	(revision 37)
+++ /trunk/src/cf_log.c	(revision 38)
@@ -84,5 +84,5 @@
 	// Initialize the present time to 0 and the timezone to UTC
 	unsigned __int64 ui64 =0;
-	static int tzflag = 0;
+	//static int tzflag = 0;
 
 	if (NULL != tv)
@@ -105,4 +105,5 @@
 	}
 
+	/*
 	if (NULL != tz)
 	{
@@ -117,4 +118,5 @@
 		tz->tz_dsttime = _daylight;
 	}
+	*/
 
 	return 0;
@@ -166,5 +168,4 @@
 		return CF_ERROR_LOG_FLUSH;
 
-	memset (ctx->buffer, 0x00, ctx->size);
 	ctx->length = 0;
 
@@ -209,5 +210,8 @@
 	else /* flush되어야 함. */
 	{
-		if (CF_File_Write (ctx->fd, buffer, demandSize) < 0)
+		ctx->buffer = (char *)buffer;
+		ctx->length = demandSize;
+
+		if (CF_Log_Local_Flush (ctx) < 0)
 			return CF_ERROR_LOG_FLUSH;
 	}
@@ -338,7 +342,5 @@
 		return CF_ERROR_LOG_INVALID_CTX;
 
-	memset (context->path, 0x00, sizeof (context->path));
-
-	if (context->buffer != NULL)
+	if (context->size > 0)
 	{
 		CF_Log_Flush (ctx);
Index: /trunk/test/makefile
===================================================================
--- /trunk/test/makefile	(revision 37)
+++ /trunk/test/makefile	(revision 38)
@@ -81,5 +81,5 @@
 	make dep
 	$(LD) $(LDFLAGS) $(LIBS) $(CDEFS) $(CFLAGS) $(INCLUDES) -o $(TARGET_PATH)/$@.$(EXT_EXECUTE) $?
-	LD_LIBRARY_PATH=$(TARGET_PATH) $(TARGET_PATH)/$@.$(EXT_EXECUTE)
+	cd $(TARGET_PATH); LD_LIBRARY_PATH=. ./$@.$(EXT_EXECUTE)
 
 clean: dummy
Index: /trunk/test/test.c
===================================================================
--- /trunk/test/test.c	(revision 37)
+++ /trunk/test/test.c	(revision 38)
@@ -29,8 +29,22 @@
 const char * file = "./log.txt";
 
+CF_THREAD_RETURN CF_THREAD_CALL test_log_mt (void * arg)
+{
+	int i = 0;
+	int th = *((int *)arg);
+
+	for (i = 0 ; i < 100000 ; i++)
+	{
+		CF_Log_Write (gLogCtx, "LOG_MT", "[%d] multi-threadedlogging test %d\n", th, i);
+	}
+
+	return (CF_THREAD_RETURN)0;
+}
+
 void test_log (const char * message)
 {
 	int			i, j;
 	char		idname[16] = {0x00,};
+	CF_Thread	tid[10];
 
 	CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
@@ -44,5 +58,5 @@
 		CF_DEBUG_PRINT (stderr, "create log ctx error\n");
 
-	for (i = 0 ; i < 10000 ; i++)
+	for (i = 0 ; i < 1000 ; i++)
 		CF_Log_Write (gLogCtx, "LOG_TEST", "turn %d\n", i);
 
@@ -74,4 +88,31 @@
 	/* }}} id */
 
+	/* mt {{{ */
+	gLogCtx = CF_Log_CreateCtx ("log_mt.txt", CF_LOG_BUFFER_DEFAULT);
+	if (gLogCtx == NULL)
+		CF_DEBUG_PRINT (stderr, "create log ctx error\n");
+
+	if (CF_Log_SetMultiThread (gLogCtx) < 0)
+		CF_DEBUG_PRINT (stderr, "set multi-threading mode error\n");
+
+	for (i = 0 ; i < 10 ; i++)
+	{
+		if (CF_Thread_Create (&tid[i], test_log_mt, &i) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to create %dth thread\n", i);
+			return ;
+		}
+		CF_DEBUG_PRINT (stderr, "created %dth thread\n", i);
+	}
+
+	for (i = 0 ; i < 10 ; i++)
+	{
+		if (CF_Thread_Join (&tid[i]) < 0)
+			CF_DEBUG_PRINT (stderr, "failed to join %dth thread\n", i);
+	}
+
+	CF_Log_DestroyCtx (gLogCtx);
+	/* }}} mt */
+
 	/* finalize */
 	CF_Log_Finalize ();
@@ -89,11 +130,11 @@
 		CF_DEBUG_TRACE (gDebugCtx, "what the ... file open ?\n");
 
-	if (CF_File_Read (fd, buffer, sizeof (buffer) - 1) < 0)
+	if (CF_File_Read (fd, buffer, sizeof (buffer)) < 0)
 		CF_DEBUG_TRACE (gDebugCtx, "what the ... file read ?\n");
 	else
 		CF_DEBUG_TRACE_BIN (gDebugCtx, (unsigned char *)buffer,
-										sizeof (buffer) - 1,
+										sizeof (buffer),
 										"-- %d bytes of %d bytes\n",
-										sizeof (buffer) - 1,
+										sizeof (buffer),
 										CF_File_GetSize (fd));
 
@@ -134,4 +175,5 @@
 	int recvd = 0;
 	char buf[1024] = {0x00,};
+	int i = 0;
 
 	/*------------------------------------------------------------*/
@@ -142,22 +184,23 @@
 		return (CF_THREAD_RETURN)-1;
 	}
-	CF_DEBUG_PRINT (stderr, "SERVER : accepted\n");
 	CF_Log_Write (gLogCtx, "SERVER", "accepted\n");
 
-	if ((recvd = CF_Socket_Recv (clntsock, buf, sizeof (buf))) < 0)
-	{
-		CF_DEBUG_PRINT (stderr, "failed to recv on server\n");
-		return (CF_THREAD_RETURN)-2;
-	}
-	CF_DEBUG_PRINT (stderr, "SERVER : recv {%s}\n", buf);
-	CF_Log_Write (gLogCtx, "SERVER", "recv {%s}\n", buf);
-
-	if (CF_Socket_Send (clntsock, buf, recvd) < 0)
-	{
-		CF_DEBUG_PRINT (stderr, "failed to send on server\n");
-		return (CF_THREAD_RETURN)-3;
-	}
-	CF_DEBUG_PRINT (stderr, "SERVER : resp {%s}\n", buf);
-	CF_Log_Write (gLogCtx, "SERVER", "resp {%s}\n", buf);
+	for (i = 0 ; i < 100 ; i++)
+	{
+		if ((recvd = CF_Socket_Recv (clntsock, buf, sizeof (buf))) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to recv on server\n");
+			return (CF_THREAD_RETURN)-2;
+		}
+		CF_Log_Write (gLogCtx, "SERVER", "recv {%s}\n", buf);
+
+		if (CF_Socket_Send (clntsock, buf, recvd) < 0)
+		{
+			return (CF_THREAD_RETURN)-3;
+		}
+		CF_Log_Write (gLogCtx, "SERVER", "resp {%s}\n", buf);
+	}
+
+	CF_Socket_Close (clntsock);
 
 	return (CF_THREAD_RETURN)0;
@@ -170,4 +213,5 @@
 	int recvd = 0;
 	char buf[1024] = {0x00,};
+	int i = 0;
 
 	sprintf (buf, "...wow ? is it succeed ?");
@@ -180,24 +224,24 @@
 		return (CF_THREAD_RETURN)-1;
 	}
-	CF_DEBUG_PRINT (stderr, "CLIENT : connected\n");
 	CF_Log_Write (gLogCtx, "CLIENT", "connected\n");
 
-	if (CF_Socket_Send (sock, buf, sizeof (buf)) < 0)
-	{
-		CF_DEBUG_PRINT (stderr, "failed to send on client %d\n", errno);
-		return (CF_THREAD_RETURN)-2;
-	}
-	CF_DEBUG_PRINT (stderr, "CLIENT : sent {%s}\n", buf);
-	CF_Log_Write (gLogCtx, "CLIENT", "sent {%s}\n", buf);
-
-	memset (buf, 0x00, sizeof (buf));
-
-	if ((recvd = CF_Socket_Recv (sock, buf, sizeof (buf))) < 0)
-	{
-		CF_DEBUG_PRINT (stderr, "failed to recv on client\n");
-		return (CF_THREAD_RETURN)-3;
-	}
-	CF_DEBUG_PRINT (stderr, "CLIENT : recv {%s}\n", buf);
-	CF_Log_Write (gLogCtx, "CLIENT", "recv {%s}\n", buf);
+	for (i = 0 ; i < 100 ; i++)
+	{
+		if (CF_Socket_Send (sock, buf, sizeof (buf)) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to send on client %d\n", errno);
+			return (CF_THREAD_RETURN)-2;
+		}
+		CF_Log_Write (gLogCtx, "CLIENT", "sent {%s}\n", buf);
+
+		memset (buf, 0x00, sizeof (buf));
+
+		if ((recvd = CF_Socket_Recv (sock, buf, sizeof (buf))) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to recv on client\n");
+			return (CF_THREAD_RETURN)-3;
+		}
+		CF_Log_Write (gLogCtx, "CLIENT", "recv {%s}\n", buf);
+	}
 
 	CF_Socket_Close (sock);
@@ -267,5 +311,4 @@
 	for (iter = 0 ; iter < THREAD_POOL ; iter++)
 	{
-		CF_DEBUG_PRINT (stderr, "tid[%d] 0x%08x\n", iter, tid[iter]);
 		CF_Thread_Join (&tid[iter]);
 		CF_Thread_Release (&tid[iter]);
@@ -300,5 +343,5 @@
 
 	// 4
-	CF_DEBUG_PRINT (stderr, " == MULTI-THREADED SOCKET TEST with MULTI-THREADED LOGGING ==\n");
+	CF_DEBUG_PRINT (stderr, " == MULTI-THREADED SOCKET TEST ==\n");
 	test_socket ();
 
