Browse Source

Z991239-351 #comment 处理 64bit 兼容的问题(部分)

gifur 5 years ago
parent
commit
2475d11297

+ 19 - 2
Common/SpFSM.h

@@ -6,6 +6,23 @@
 #include "SpBase.h"
 #include "ListEntry.h"
 
+#ifndef PARAM_SIZE_DEFINED
+#define PARAM_SIZE_DEFINED
+
+#ifdef _WIN32
+typedef int param_size_t;
+#else
+#if defined(__x86_64__)
+typedef intptr_t param_size_t;
+#elif defined(__i386__)
+typedef int param_size_t;
+#else
+typedef intptr_t param_size_t;
+#endif
+#endif //_WIN32
+
+#endif // !PARAM_SIZE_DEFINED
+
 /** finite state machine */
 
 enum FSMEventEnum
@@ -21,8 +38,8 @@ enum FSMEventEnum
 struct FSMEvent
 {
 	int iEvt;
-	int param1;
-	int param2;
+	param_size_t param1;
+	param_size_t param2;
 	
 	FSMEvent(int evt) : m_ref_cnt(1), iEvt(evt), m_bHandled(FALSE) { m_entry.Flink = m_entry.Blink = &m_entry; }
 	virtual ~FSMEvent() {}

+ 0 - 1
Common/SpHelper.h

@@ -151,7 +151,6 @@ static inline ErrorCodeEnum SpWaitAnswerObject(const CSmartPointer<IAsynWaitSp>
 	if (Error == Error_Succeed) {
 		CAutoBuffer Buf;
 		Error = pAsyncWait->AsyncGetAnswer(Buf, bEnd);
-		Dbg("SpWaitAnswerObject buffer:%s", Buf);
 		if (Error == Error_Succeed) {
 			Error = SpBuffer2Object(Buf, t);
 		}

+ 24 - 3
libtoolkit/bus-unix.c

@@ -310,7 +310,7 @@ static int tcp_recv_buf(bus_endpt_t* endpt, char* buf, DWORD n)
 {
 	DWORD left = n;
 	DWORD offset = 0;
-
+	WLog_DBG(TAG, "==> fd(%d): tcp recv buf len: %d", endpt->sock_handle, n);
 	while (left > 0) {
 		BOOL ret;
 		DWORD dwBytesTransfer;
@@ -406,6 +406,7 @@ static int start_read_pkt(bus_endpt_t* endpt, iobuffer_t** p_pkt)
 	*p_pkt = NULL;
 	WLog_DBG(TAG, "==>endpt(%d): start_read_pkt", endpt->epid);
 	ResetEvent(endpt->rx_evt);
+	WLog_DBG(TAG, "ResetEvent(endpt->rx_evt) ???");
 	endpt->rx_pending_pkt_uc_len = 0;
 
 	if (endpt->type == TYPE_PIPE) {
@@ -416,33 +417,50 @@ static int start_read_pkt(bus_endpt_t* endpt, iobuffer_t** p_pkt)
 			&endpt->rx_overlapped);
 	}
 	else if (endpt->type == TYPE_TCP) {
-		ret = _recv(endpt->sock_handle, (char*)&endpt->rx_pending_pkt_len, 4, 0);
+		do {
+			WLog_DBG(TAG, "_recv ???");
+			ret = _recv(endpt->sock_handle, (char*)&endpt->rx_pending_pkt_len, 4, 0);
+
+		} while (ret < 0 && errno == EINTR);
+		WLog_DBG(TAG, "_recv return: %d, %d", ret, errno);
 	}
 	else {
+		WLog_ERR(TAG, "<== endpt(%d): start_read_pkt unkonwn type", endpt->epid);
 		return -1;
 	}
 	if (ret >= 0) {
 		dwBytesTransferred = ret;
 		endpt->rx_pending_pkt_uc_len = ret;
-		if (dwBytesTransferred == 0)
+		if (dwBytesTransferred == 0) {
+			WLog_ERR(TAG, "<== endpt(%d): start_read_pkt dwBytesTransferred is error.", endpt->epid);
 			return -1;
+		}
 		if (dwBytesTransferred < 4) {
+			WLog_DBG(TAG, "endpt(%d): receive buffer less than dream len", endpt->epid);
 			rc = recv_buf(endpt, (char*)&endpt->rx_pending_pkt_len + dwBytesTransferred, 4 - dwBytesTransferred);
 			if (rc < 0) {
+				WLog_ERR(TAG, "<== endpt(%d): start_read_pkt recv_buf error.", endpt->epid);
 				return rc;
 			}
 		}
+		WLog_DBG(TAG, "iobuffer_create ???");
 		pkt = iobuffer_create(0, endpt->rx_pending_pkt_len);
 		endpt->rx_pending_pkt_uc_len = 0;
 		if (endpt->rx_pending_pkt_len > 0) {
+			WLog_DBG(TAG, "endpt->rx_pending_pkt_len > 0 ???");
 			rc = recv_buf(endpt, iobuffer_data(pkt, 0), endpt->rx_pending_pkt_len);
 			if (rc < 0) {
+				WLog_DBG(TAG, "iobuffer_destroy ???");
 				iobuffer_destroy(pkt);
+				WLog_ERR(TAG, "<== endpt(%d): start_read_pkt recv_buf error.", endpt->epid);
 				return rc;
 			}
+			WLog_DBG(TAG, "iobuffer_push_count ???");
 			iobuffer_push_count(pkt, endpt->rx_pending_pkt_len);
 		}
+		WLog_DBG(TAG, "*p_pkt = pkt ???");
 		*p_pkt = pkt;
+		WLog_ERR(TAG, "<== endpt(%d): start_read_pkt recv_buf succ.", endpt->epid);
 		return 0;
 	}
 	else if(errno == EAGAIN || errno == EWOULDBLOCK) {
@@ -450,6 +468,7 @@ static int start_read_pkt(bus_endpt_t* endpt, iobuffer_t** p_pkt)
 		endpt->rx_pending = 1;
 		return 0;
 	}
+	WLog_ERR(TAG, "<== endpt(%d): start_read_pkt recv_buf failed.", endpt->epid);
 	return -1;
 }
 
@@ -510,9 +529,11 @@ static int append_rx_pkt(bus_endpt_t* endpt, iobuffer_t* pkt)
 	iobuffer_restore_read_state(pkt, read_state);
 	if (type == BUS_TYPE_PACKET || type == BUS_TYPE_INFO || type == BUS_TYPE_EVENT || type == BUS_TYPE_SYSTEM) {
 		iobuffer_queue_enqueue(endpt->rx_buf_queue, pkt);
+		WLog_DBG(TAG, "<== append_rx_pkt finished");
 		return 1;
 	}
 	else {
+		WLog_DBG(TAG, "<== append_rx_pkt failed!");
 		return -1;
 	}
 }

+ 1 - 1
libtoolkit/bus_daemon-unix.c

@@ -756,7 +756,7 @@ static int session_start_recv_hdr(endpt_session_t *session)
 	return rc;
 }
 
-static int on_msg(unsigned short msg_id, int param1, int param2)
+static int on_msg(unsigned short msg_id, param_size_t param1, param_size_t param2)
 {
 	WLog_DBG(TAG, "==> on_msg(id=%d, param1=%d, param2=%d)", msg_id, param1, param2);
 	if (msg_id == MSG_REMOVE_REGISTAR) {

+ 5 - 5
libtoolkit/ioqueue-unix.c

@@ -57,8 +57,8 @@ struct ioqueue_t {
 
 typedef struct ioqueue_msg {
 	int msg_type;
-	int param1;
-	int param2;
+	param_size_t param1;
+	param_size_t param2;
 	HANDLE evt; /* for send message */
 }ioqueue_msg;
 
@@ -817,7 +817,7 @@ static void dispatch_network(BOOL ret, DWORD dwBytesTransfer, ioqueue_overlapped
 	}
 }
 
-static void dispatch_msg(ioqueue_t *ioq, int msg_type, int param1, int param2, HANDLE evt)
+static void dispatch_msg(ioqueue_t *ioq, int msg_type, param_size_t param1, param_size_t param2, HANDLE evt)
 {
 	int chain = 1, i;
 	for (i = 0; chain && i < MAX_MSG_PRIORITY; ++i) {
@@ -829,7 +829,7 @@ static void dispatch_msg(ioqueue_t *ioq, int msg_type, int param1, int param2, H
 		SetEvent(evt);
 }
 
-TOOLKIT_API int ioqueue_post_message(ioqueue_t *ioq, int msg_type, int param1, int param2)
+TOOLKIT_API int ioqueue_post_message(ioqueue_t *ioq, int msg_type, param_size_t param1, param_size_t param2)
 {
 	ioqueue_msg *msg;
 	assert(ioq);
@@ -847,7 +847,7 @@ TOOLKIT_API int ioqueue_post_message(ioqueue_t *ioq, int msg_type, int param1, i
 	return 0;
 }
 
-TOOLKIT_API int ioqueue_send_message(ioqueue_t *ioq, int msg_type, int param1, int param2)
+TOOLKIT_API int ioqueue_send_message(ioqueue_t *ioq, int msg_type, param_size_t param1, param_size_t param2)
 {
 	ioqueue_msg msg = {msg_type, param1, param2};
 	assert(ioq);

+ 3 - 3
libtoolkit/ioqueue.h

@@ -32,7 +32,7 @@ typedef struct ioqueue_t ioqueue_t;
 /**
  * @return return non-zero means need continue processing
  */
-typedef int (*ioqueue_on_msg_callback)(unsigned short msg_id, int param1, int param2);
+typedef int (*ioqueue_on_msg_callback)(unsigned short msg_id, param_size_t param1, param_size_t param2);
 
 #define MAX_MSG						1024
 #define MAX_MSG_PRIORITY			32
@@ -102,12 +102,12 @@ TOOLKIT_API int ioqueue_msg_remove_handler(ioqueue_t *ioq, int msg_type, int pri
 /** 
  * post user message
  */
-TOOLKIT_API int ioqueue_post_message(ioqueue_t *ioq, int msg_type, int param1, int param2);
+TOOLKIT_API int ioqueue_post_message(ioqueue_t *ioq, int msg_type, param_size_t param1, param_size_t param2);
 
 /**
  * send message, synchronous operation
  */
-TOOLKIT_API int ioqueue_send_message(ioqueue_t *ioq, int msg_type, int param1, int param2);
+TOOLKIT_API int ioqueue_send_message(ioqueue_t *ioq, int msg_type, param_size_t param1, param_size_t param2);
 
 /**
  * cancel all message with msg_type

+ 6 - 0
libtoolkit/memutil.h

@@ -86,6 +86,9 @@ static __inline __int64 int64_make(int low_part, int high_part)
 #define FLAG_BIT(f) f##_BIT
 
 /* for compatility at different platform [3/31/2020 Gifur] */
+#ifndef PARAM_SIZE_DEFINED
+#define PARAM_SIZE_DEFINED
+
 #ifdef _WIN32
 typedef int param_size_t;
 #else
@@ -98,6 +101,9 @@ typedef intptr_t param_size_t;
 #endif
 #endif //_WIN32
 
+#endif // !PARAM_SIZE_DEFINED
+
+
 #define SAFE_INVOKE_0(lpfn) if(lpfn) lpfn()
 #define SAFE_INVOKE_1(lpfn, param1) if(lpfn) lpfn(param1)
 #define SAFE_INVOKE_2(lpfn, param1, param2) if(lpfn) lpfn(param1, param2)

+ 9 - 9
libtoolkit/threadpool.c

@@ -17,8 +17,8 @@ struct strand_task_entry {
 	threadpool_workitem_proc f;
 	threadpool_workitem_proc2 f2;
 	void *arg;
-	int param1;
-	int param2;
+	param_size_t param1;
+	param_size_t param2;
 };
 
 typedef struct strand_task_entry strand_task_entry;
@@ -30,7 +30,7 @@ struct strand_t {
 	DECLARE_REF_COUNT_MEMBER(ref_cnt);
 };
 
-static strand_task_entry *make_task_entry(strand_t *strand, threadpool_workitem_proc f, threadpool_workitem_proc2 f2, void *arg, int param1, int param2)
+static strand_task_entry *make_task_entry(strand_t *strand, threadpool_workitem_proc f, threadpool_workitem_proc2 f2, void *arg, param_size_t param1, param_size_t param2)
 {
 	strand_task_entry *task_entry = MALLOC_T(strand_task_entry);
 	task_entry->strand = strand;
@@ -389,8 +389,8 @@ static int __threadpool_queue_workitem(threadpool_t *threadpool,
 									   threadpool_workitem_proc workitem, 
 									   threadpool_workitem_proc2 workitem2, 
 									   void *arg,
-									   int param1,
-									   int param2,
+									   param_size_t param1,
+									   param_size_t param2,
 									   int fifo)
 {
 	strand_task_entry *task_entry = NULL;
@@ -444,8 +444,8 @@ TOOLKIT_API int threadpool_queue_workitem2(threadpool_t *threadpool,
 							   strand_t *strand, 
 							   threadpool_workitem_proc2 workitem, 
 							   void *arg, 
-							   int param1,
-							   int param2)
+							   param_size_t param1,
+							   param_size_t param2)
 {
 	return __threadpool_queue_workitem(threadpool, strand, NULL, workitem, arg, param1, param2, 1);
 }
@@ -462,8 +462,8 @@ TOOLKIT_API int threadpool_post_workitem_lifo2(threadpool_t *threadpool,
 								   strand_t *strand, 
 								   threadpool_workitem_proc2 workitem, 
 								   void *arg, 
-								   int param1,
-								   int param2)
+								   param_size_t param1,
+								   param_size_t param2)
 {
 	return __threadpool_queue_workitem(threadpool, strand, NULL, workitem, arg, param1, param2, 0);
 }

+ 6 - 5
libtoolkit/threadpool.h

@@ -4,6 +4,7 @@
 #pragma once
 
 #include "config.h"
+#include "memutil.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -13,7 +14,7 @@ typedef struct threadpool_t threadpool_t;
 typedef struct strand_t strand_t;
 
 typedef void (*threadpool_workitem_proc)(threadpool_t *threadpool, void *arg);
-typedef void (*threadpool_workitem_proc2)(threadpool_t *threadpool, void *arg, int param1, int param2);
+typedef void (*threadpool_workitem_proc2)(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2);
 typedef void (*threadpool_decorator_callback)(threadpool_t *threadpool, void *user_data);
 
 TOOLKIT_API int threadpool_create(threadpool_t **p_threadpool);
@@ -36,8 +37,8 @@ TOOLKIT_API int threadpool_queue_workitem2(threadpool_t *threadpool,
 							  strand_t *strand, 
 							  threadpool_workitem_proc2 workitem, 
 							  void *arg, 
-							  int param1,
-							  int param2);
+							  param_size_t param1,
+							  param_size_t param2);
 
 #define threadpool_post_workitem_fifo threadpool_queue_workitem
 #define threadpool_post_workitem_fifo2 threadpool_queue_workitem2
@@ -50,8 +51,8 @@ TOOLKIT_API int threadpool_post_workitem_lifo2(threadpool_t *threadpool,
 								   strand_t *strand, 
 								   threadpool_workitem_proc2 workitem, 
 								   void *arg, 
-								   int param1,
-								   int param2);
+								   param_size_t param1,
+								   param_size_t param2);
 
 TOOLKIT_API void threadpool_set_user_data(threadpool_t *threadpool, void *user_data);
 TOOLKIT_API void *threadpool_get_user_data(threadpool_t *threadpool);

+ 3 - 3
spbase/SpAsyncWait.cpp

@@ -277,7 +277,7 @@ void SpAsyncWait::ReceiveAnsPkt(int error, int end, iobuffer_t **ans_pkt, bool b
 			, m_callback_strand
 			, &__threadpool_on_callback
 			, this
-			, (int)((intptr_t)wce)
+			, (param_size_t)wce
 			, NULL);
 	}
 	spinlock_leave(&m_lock);
@@ -337,7 +337,7 @@ void SpAsyncWait::SetCallback(ICallbackListener *pCallback,IReleasable *pContext
 				, m_callback_strand
 				, &__threadpool_on_callback
 				, this
-				, (int)((intptr_t)wce)
+				, (param_size_t)wce
 				, NULL);
 		}
 	} else { // cancel callback
@@ -380,7 +380,7 @@ void SpAsyncWait::threadpool_on_callback(SpAsyncWait::wait_callback_entry *wce)
 	}
 }
 
-void SpAsyncWait::__threadpool_on_callback(threadpool_t *threadpool, void *arg, int param1, int param2)
+void SpAsyncWait::__threadpool_on_callback(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	SpAsyncWait *pThis = static_cast<SpAsyncWait*>(arg);
 	wait_callback_entry *wce = (wait_callback_entry *)param1;

+ 1 - 1
spbase/SpAsyncWait.h

@@ -98,7 +98,7 @@ protected:
 	struct list_head m_pending_callback_list;
 	strand_t *m_callback_strand;
 	void threadpool_on_callback(struct wait_callback_entry *wce);
-	static void __threadpool_on_callback(threadpool_t *threadpool, void *arg, int param1, int param2);
+	static void __threadpool_on_callback(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2);
 
 	DWORD m_dwMessageID;
 	SpEntity *m_pEntity;

+ 0 - 1
spbase/SpBase.cpp

@@ -176,7 +176,6 @@ SPBASE_API void LogAssert(const char *pszMessage,const char *pszFile,const int n
 
 SPBASE_API void LogTrace(const char *pszMessage,const char *pszFile,const int nLine)
 {
-	sp_dbg_debug("========Trace: {%s}, file: {%s}, line: {%d}", pszMessage, _GetFileName(pszFile), nLine);
 	SpModule *pModule = GetSpModule();
 	if (pModule) {		
 		pModule->LogMessage(Log_Debug, Severity_None, 0, 0, pszMessage);

+ 4 - 4
spbase/SpEntity.cpp

@@ -141,7 +141,7 @@ static void on_log(void *inst,
 	
 }
 
-static void task_callback(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void task_callback(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	ITaskSp *pTask = (ITaskSp*)arg;
 	SpEntity *pEntity = (SpEntity*)param1;
@@ -1627,7 +1627,7 @@ ErrorCodeEnum SpEntity::PostEntityTaskFIFO(ITaskSp *pTask)
 	threadpool_t *threadpool = sp_svc_get_threadpool(m_svc);
 	int rc;
 
-	rc = threadpool_post_workitem_fifo2(threadpool, NULL, &task_callback, pTask, (int)((intptr_t)this), 0);
+	rc = threadpool_post_workitem_fifo2(threadpool, NULL, &task_callback, pTask, (param_size_t)((intptr_t)this), 0);
 
 	return rc == 0 ? Error_Succeed : Error_Unexpect;
 }
@@ -1637,14 +1637,14 @@ ErrorCodeEnum SpEntity::PostEntityTaskLIFO(ITaskSp *pTask)
 	threadpool_t *threadpool = sp_svc_get_threadpool(m_svc);
 	int rc;
 
-	rc = threadpool_post_workitem_lifo2(threadpool, NULL, &task_callback, pTask, (int)((intptr_t)this), 0);
+	rc = threadpool_post_workitem_lifo2(threadpool, NULL, &task_callback, pTask, (param_size_t)((intptr_t)this), 0);
 
 	return rc == 0 ? Error_Succeed : Error_Unexpect;
 }
 
 ErrorCodeEnum SpEntity::PostThreadPoolTask(ITaskSp *pTask)
 {
-	int rc = threadpool_post_workitem_fifo2(m_tpool, NULL, &task_callback, pTask, (int)((intptr_t)this), 0);
+	int rc = threadpool_post_workitem_fifo2(m_tpool, NULL, &task_callback, pTask, (param_size_t)((intptr_t)this), 0);
 	return rc == 0 ? Error_Succeed : Error_Unexpect;
 }
 

+ 8 - 1
spbase/SpEntityPrivilege.cpp

@@ -35,7 +35,14 @@
 #include <winpr/crt.h>
 #endif //_WIN32
 
-static ErrorCodeEnum ControlEntity(SpEntity *pEntity, const char *pszEntityName, int call_type, const char *cmd_line, int param1, int param2, CSmartPointer<IAsynWaitSp> &pAsynWaitSp)
+static ErrorCodeEnum ControlEntity(
+	SpEntity *pEntity, 
+	const char *pszEntityName,
+	int call_type, 
+	const char *cmd_line,
+	//don't change this type bcz: 1. ipc would not convey pointer-type, and receiver may receive as 4bytes type.  [4/2/2020 11:13 Gifur]
+	int param1, int param2,
+	CSmartPointer<IAsynWaitSp> &pAsynWaitSp)
 {
 	if (!pszEntityName)
 		return Error_Null;

+ 5 - 5
spbase/SpFSM.cpp

@@ -23,7 +23,7 @@ struct FSMTimer
 	FSMTimer(FSMBase *o) : timer(NULL), owner(o) { ListEntry_InitNode(&entry); }
 };
 
-static void __fsm_cb(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __fsm_cb(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	FSMEvent *e = static_cast<FSMEvent*>(arg);
 	FSMBase *pFSM = (FSMBase*)param1;
@@ -52,7 +52,7 @@ static void __tmr_cb(sp_tmr_t *timer, int err, void *user_data)
 			if (pTimer->entry.Flink) {
 				ListEntry_DeleteNode(&pTimer->entry);
 				FSMEvent *e = new FSMEvent(EVT_TIMER);
-				e->param1 = pTimer->iTimerId;
+				e->param1 = (int)pTimer->iTimerId;
 				pTimer->owner->__ProcessEvent(e);
 				e->DecRef();
 			}
@@ -131,7 +131,7 @@ void FSMBase::PostEventLIFO(FSMEvent *e)
 	try
 	{
 		SpEntity *pEntity = dynamic_cast<SpEntity*>(m_pEntity->m_pEntityFunction);
-		threadpool_post_workitem_lifo2(sp_svc_get_threadpool(pEntity->get_svc()), (strand_t*)m_strand, &__fsm_cb, e, (int)(intptr_t)this, 0);
+		threadpool_post_workitem_lifo2(sp_svc_get_threadpool(pEntity->get_svc()), (strand_t*)m_strand, &__fsm_cb, e, (param_size_t)(intptr_t)this, 0);
 	}
 	catch (...)
 	{
@@ -147,7 +147,7 @@ void FSMBase::PostEventFIFO(FSMEvent *e)
 	try
 	{
 		SpEntity *pEntity = dynamic_cast<SpEntity*>(m_pEntity->m_pEntityFunction);
-		threadpool_post_workitem_fifo2(sp_svc_get_threadpool(pEntity->get_svc()), (strand_t*)m_strand, &__fsm_cb, e, (int)(intptr_t)this, 0);
+		threadpool_post_workitem_fifo2(sp_svc_get_threadpool(pEntity->get_svc()), (strand_t*)m_strand, &__fsm_cb, e, (param_size_t)(intptr_t)this, 0);
 	}
 	catch (...)
 	{
@@ -163,7 +163,7 @@ void FSMBase::Trans( int next )
 	{
 		if (next != m_iState) {
 			FSMEvent *e = new FSMEvent(EVT_INTERNAL); // @
-			e->param1 = next;
+			e->param1 = (int)next;
 			PostEventFIFO(e);
 			m_lInTrans++;
 		}

+ 1 - 0
spbase/sp_bcm.c

@@ -47,6 +47,7 @@ int sp_bcm_client_bcast(sp_bcm_client_t *client, int message_id, int message_sig
 	int rc;
 	iobuffer_write_head(*p_pkt, IOBUF_T_I4, &message_sig, 0);
 	iobuffer_write_head(*p_pkt, IOBUF_T_I4, &message_id, 0);
+	//TODO: 
 	iobuffer_write_head(*p_pkt, IOBUF_T_I4, &client_id, 0);
 
 	//sp_dbg_info("send broadcast");

+ 0 - 2
spbase/sp_mod.c

@@ -267,8 +267,6 @@ static int mod_entity_on_pkt(sp_svc_t *svc, int epid, int svc_id, int pkt_type,
 				iobuffer_write_head(pkt, IOBUF_T_I4, &svc_id, 0);
 				iobuffer_write_head(pkt, IOBUF_T_I4, &epid, 0);
 				iobuffer_write_head(pkt, IOBUF_T_PTR, &stub, 0);
-				sp_dbg_debug("stub address: intptr 0x%016X", (intptr_t)stub);
-				sp_dbg_debug("stub address: int 0x%016X", (int)stub);
 				threadpool_queue_workitem(sp_svc_get_threadpool(stub->svc), stub->strand, &mod_entity_process_cmd, pkt);
 				return FALSE;
 		}

+ 4 - 4
spbase/sp_rpc.c

@@ -39,7 +39,7 @@ struct sp_rpc_server_t
 
 DECLARE_REF_COUNT_STATIC(sp_rpc_server, sp_rpc_server_t)
 
-static void __threadpool_server_on_pkt(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_server_on_pkt(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_rpc_server_t *server = (sp_rpc_server_t *)arg;
 	iobuffer_t *pkt = (iobuffer_t*)param1;
@@ -86,7 +86,7 @@ static int server_on_pkt(sp_svc_t *svc, int epid, int svc_id, int pkt_type, int
 	iobuffer_write_head(pkt, IOBUF_T_I4, &epid, 0);
 
 	sp_rpc_server_inc_ref(server); // @
-	rc = threadpool_queue_workitem2(sp_svc_get_threadpool(svc), NULL, &__threadpool_server_on_pkt, server, (int)pkt, 0);
+	rc = threadpool_queue_workitem2(sp_svc_get_threadpool(svc), NULL, &__threadpool_server_on_pkt, server, (param_size_t)pkt, 0);
 	if (rc != 0) {
 		sp_rpc_server_dec_ref(server); // @
 		iobuffer_dec_ref(pkt);
@@ -204,7 +204,7 @@ static __inline void client_unlock(sp_rpc_client_t *client)
 static void client_set_error(sp_rpc_client_t *client, int error);
 static void client_process_ans(sp_rpc_client_t *client, iobuffer_t **ans_pkt);
 
-static void __threadpool_mgr_on_req(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_mgr_on_req(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_rpc_client_mgr_t *mgr = (sp_rpc_client_mgr_t *)arg;
 	iobuffer_t *pkt = (iobuffer_t*)param1;
@@ -269,7 +269,7 @@ static int mgr_on_pkt(sp_svc_t *svc,int epid, int svc_id, int pkt_type, int pkt_
 		iobuffer_write_head(pkt, IOBUF_T_I4, &epid, 0);
 		
 		sp_rpc_client_mgr_inc_ref(mgr);
-		rc = threadpool_queue_workitem2(sp_svc_get_threadpool(svc), NULL, &__threadpool_mgr_on_req, mgr, (int)pkt, 0);
+		rc = threadpool_queue_workitem2(sp_svc_get_threadpool(svc), NULL, &__threadpool_mgr_on_req, mgr, (param_size_t)pkt, 0);
 		if (rc != 0) {
 			sp_rpc_client_mgr_dec_ref(mgr); // @
 			iobuffer_dec_ref(pkt);

+ 12 - 12
spbase/sp_ses.c

@@ -351,7 +351,7 @@ static void mgr_process_fins(sp_ses_mgr_t *mgr, int epid, int svc_id, int conn_i
 	mgr_process_errs(mgr, epid, svc_id, conn_id, Error_PeerClose);
 }
 
-static void __threadpool_mgr_process_conn(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_mgr_process_conn(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_ses_mgr_t *mgr = (sp_ses_mgr_t*)arg;
 	iobuffer_t *conn_pkt = (iobuffer_t*)param1;
@@ -454,7 +454,7 @@ static void mgr_process_conn(sp_ses_mgr_t *mgr, int epid, int svc_id, int conn_i
 	iobuffer_write_head(*conn_pkt, IOBUF_T_I4, &epid, 0);
 
 	sp_ses_mgr_inc_ref(mgr); // @
-	err = threadpool_queue_workitem2(sp_svc_get_threadpool(mgr->svc), NULL, &__threadpool_mgr_process_conn, mgr, (int)*conn_pkt, 0);
+	err = threadpool_queue_workitem2(sp_svc_get_threadpool(mgr->svc), NULL, &__threadpool_mgr_process_conn, mgr, (param_size_t)*conn_pkt, 0);
 	if (err)
 	{
 		iobuffer_t *pkt = iobuffer_create(-1, -1);
@@ -834,12 +834,12 @@ static void uac_process_errs(sp_ses_uac_t *uac, int error)
 	uac_unlock(uac);
 }
 
-static void __threadpool_uac_trigger_close(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_uac_trigger_close(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_ses_uac_t *uac = (sp_ses_uac_t*)arg;
 	sp_ses_mgr_t *mgr = uac->mgr;
 	
-	int error = param1;
+	int error = (int)param1;
 	sp_uid_t rsn = sp_svc_new_runserial(mgr->svc);
 	sp_rsn_context_t rsn_ctx;
 	sp_rsn_context_init_original(rsn, SP_ORIGINAL_T_FRAMEWORK, &rsn_ctx);
@@ -1479,11 +1479,11 @@ static void uas_process_errc(sp_ses_uas_t *uas, int error)
 		uas_trigger(uas, error);
 }
 
-static void __threadpool_uas_trigger(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_uas_trigger(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_ses_uas_t *uas = (sp_ses_uas_t*)arg;
 	sp_ses_mgr_t *mgr = uas->mgr;
-	int error = param1;
+	int error = (int)param1;
 	sp_uid_t rsn = sp_svc_new_runserial(mgr->svc);
 	sp_rsn_context_t rsn_ctx;
 	sp_rsn_context_init_original(rsn, SP_ORIGINAL_T_FRAMEWORK, &rsn_ctx);
@@ -1524,11 +1524,11 @@ static strand_t *uas_get_strand(sp_ses_uas_t *uas, int method_id)
 	return ms->strand;
 }
 
-static void __threadpool_uas_process_info(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_uas_process_info(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_ses_uas_t *uas = (sp_ses_uas_t*)arg;
 	sp_ses_mgr_t *mgr = uas->mgr;
-	int method_id = param1;
+	int method_id = (int)param1;
 	int method_sig;
 	iobuffer_t *info_pkt = (iobuffer_t*)param2;
 
@@ -1583,7 +1583,7 @@ static void uas_process_info(sp_ses_uas_t *uas, int method_id, int method_sig, i
 		strand_t *strand = uas_decide_strand(uas, method_id, overlap);
 		iobuffer_write_head(*info_pkt, IOBUF_T_I4, &method_sig, 0);
 		sp_ses_uas_inc_ref(uas); //@
-		rc = threadpool_queue_workitem2(sp_svc_get_threadpool(uas->mgr->svc), strand, &__threadpool_uas_process_info, uas, method_id, (int)*info_pkt);
+		rc = threadpool_queue_workitem2(sp_svc_get_threadpool(uas->mgr->svc), strand, &__threadpool_uas_process_info, uas, method_id, (param_size_t)*info_pkt);
 		if (rc != 0) {
 			sp_dbg_warn("process info queue work item failed!");
 			sp_ses_uas_dec_ref(uas); //@
@@ -1611,11 +1611,11 @@ static void uas_process_req_reply_error(sp_ses_uas_t *uas, int tsx_id, int err)
 		iobuffer_dec_ref(ans_pkt);
 }
 
-static void __threadpool_uas_process_req(threadpool_t *threadpool, void *arg, int param1, int param2)
+static void __threadpool_uas_process_req(threadpool_t *threadpool, void *arg, param_size_t param1, param_size_t param2)
 {
 	sp_ses_uas_t *uas = (sp_ses_uas_t*)arg;
 	sp_ses_mgr_t *mgr = uas->mgr;
-	int tsx_id = param1;
+	int tsx_id = (int)param1;
 	int method_id;
 	int method_sig;
 	int timeout;
@@ -1658,7 +1658,7 @@ static void uas_process_req(sp_ses_uas_t *uas, int tsx_id, int method_id, int me
 		iobuffer_write_head(*req_pkt, IOBUF_T_I4, &method_sig, 0);
 		iobuffer_write_head(*req_pkt, IOBUF_T_I4, &method_id, 0);
 		sp_ses_uas_inc_ref(uas); //@
-		rc = threadpool_queue_workitem2(sp_svc_get_threadpool(uas->mgr->svc), strand, &__threadpool_uas_process_req, uas, tsx_id, (int)*req_pkt);
+		rc = threadpool_queue_workitem2(sp_svc_get_threadpool(uas->mgr->svc), strand, &__threadpool_uas_process_req, uas, tsx_id, (param_size_t)*req_pkt);
 		if (rc != 0) {
 			uas_process_req_reply_error(uas, tsx_id, rc);
 			sp_dbg_warn("process req queue work item failed!");

+ 4 - 4
spbase/sp_tbs.c

@@ -69,8 +69,8 @@ typedef struct sock_connection sock_connection;
 struct cmd_entry {
 	struct list_head entry;
 	int msg;
-	int param1;
-	int param2;
+	param_size_t param1;
+	param_size_t param2;
 };
 
 struct sub_session {
@@ -152,7 +152,7 @@ static void uac_on_close(sp_tbs_t *tbs, sock_connection *conn, sub_session *sess
 static void uac_on_ans(sp_tbs_t *tbs, sock_connection *conn, sub_session *session, int tsx_id, int error, int user_error, int end, iobuffer_t **ans_pkt);
 static void uac_on_destroy(sp_tbs_t *tbs, sock_connection *conn, sub_session *session);
 
-static void post_msg(sp_tbs_t *tbs, int msg, int param1, int param2);
+static void post_msg(sp_tbs_t *tbs, int msg, param_size_t param1, param_size_t param2);
 static void destroy_sub_session(sp_tbs_t *tbs, sock_connection *conn, sub_session *session);
 
 static const wchar_t *get_err_msg(int rc)
@@ -1189,7 +1189,7 @@ static void on_accept(sp_tbs_t *tbs)
 	}
 }
 
-static void post_msg(sp_tbs_t *tbs, int msg, int param1, int param2)
+static void post_msg(sp_tbs_t *tbs, int msg, param_size_t param1, param_size_t param2)
 {
 	cmd_entry *e = MALLOC_T(cmd_entry);
 	e->msg = msg;

+ 1 - 1
test/module/mod_helloclient/CMakeLists.txt

@@ -10,7 +10,7 @@ target_include_directories(${MODULE_NAME}
 )
 
 # 添加实体需要依赖的其他共享库(包括系统库)
-set(${MODULE_PREFIX}_LIBS spbase)
+set(${MODULE_PREFIX}_LIBS spbase winpr)
 target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
 
 deploy_module(${MODULE_PREFIX} ${MODULE_NAME})

+ 3 - 0
test/module/mod_helloclient/mod_helloclient.cpp

@@ -3,6 +3,8 @@
 
 #include "HelloService_client_g.h"
 
+#include <winpr/synch.h>
+
 using namespace HelloService;
 
 class HelloClientEntity : public CEntityBase, public ITimerListener, public ISysVarListener
@@ -34,6 +36,7 @@ public:
 		//pFunc->RegistSysVarEvent("HelloState", this);
 
 #if 1
+		Sleep(60 * 1000);
 		HelloService_ClientBase *client = new HelloService_ClientBase(this);
 		Dbg("before connect");
 		ErrorCodeEnum Error = client->Connect();

+ 1 - 1
test/module/mod_helloservice/mod_helloservice.cpp

@@ -17,7 +17,7 @@ public:
 	virtual void Handle_Hello(SpReqAnsContext<HelloService_Hello_Req, HelloService_Hello_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
-		LOG_TRACE("handle hello msg %s!", ctx->Req.txt);
+		LOG_TRACE("handle hello msg %s!", (LPCTSTR)ctx->Req.txt);
 		ctx->Ans.txt = "Hello, this message comes from Hello Service entity!";
 		ctx->Answer();
 	}