diff --git a/interfaces/innerkits/c/dbinder/include/dbinder_service.h b/interfaces/innerkits/c/dbinder/include/dbinder_service.h index 42331b8ccb23f5be500edd0371fef1b404306227..1fb32b274f2af3bc0ab4dfc658bc13d63e57217f 100644 --- a/interfaces/innerkits/c/dbinder/include/dbinder_service.h +++ b/interfaces/innerkits/c/dbinder/include/dbinder_service.h @@ -19,10 +19,8 @@ #include #ifdef __cplusplus -#if __cplusplus extern "C" { #endif -#endif int32_t StartDBinderService(void); int32_t RegisterRemoteProxy(const void *name, uint32_t len, int32_t systemAbility); @@ -30,8 +28,6 @@ int32_t MakeRemoteBinder(const void *serviceName, uint32_t nameLen, const char * uintptr_t binderObject, uint64_t pid, void *remoteObject); #ifdef __cplusplus -#if __cplusplus } #endif /* __cplusplus */ -#endif /* __cplusplus */ #endif /* DBINDER_SERVICE_H */ \ No newline at end of file diff --git a/interfaces/innerkits/c/ipc/include/ipc_skeleton.h b/interfaces/innerkits/c/ipc/include/ipc_skeleton.h index fb3e1da28c7460fba69080aeda627001bbf82d93..58ae84ca6203692520b01f166ef47eb2917b4cc5 100644 --- a/interfaces/innerkits/c/ipc/include/ipc_skeleton.h +++ b/interfaces/innerkits/c/ipc/include/ipc_skeleton.h @@ -24,9 +24,7 @@ #include "serializer.h" #ifdef __cplusplus -#if __cplusplus extern "C" { -#endif #endif /* __cplusplus */ enum { @@ -78,8 +76,6 @@ int32_t MessageOptionInit(MessageOption *option); int32_t ReleaseSvc(SvcIdentity target); #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_SKELETON_H */ diff --git a/interfaces/innerkits/c/ipc/include/serializer.h b/interfaces/innerkits/c/ipc/include/serializer.h index d09e1ab6574ffbbe8c5f6b3b19db69fd403eea1a..ed6adb3671b0431fd17b263a991eb9f6ab6b7cae 100644 --- a/interfaces/innerkits/c/ipc/include/serializer.h +++ b/interfaces/innerkits/c/ipc/include/serializer.h @@ -21,10 +21,8 @@ #include #ifdef __cplusplus -#if __cplusplus extern "C" { #endif /* __cplusplus */ -#endif /* __cplusplus */ typedef struct { char *bufferBase; @@ -128,9 +126,7 @@ float *ReadFloatVector(IpcIo *io, size_t *size); double *ReadDoubleVector(IpcIo *io, size_t *size); #ifdef __cplusplus -#if __cplusplus } #endif /* __cplusplus */ -#endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_SERIALIZER_H */ diff --git a/ipc/native/c/adapter/include/rpc_os_adapter.h b/ipc/native/c/adapter/include/rpc_os_adapter.h index 128af4f127e3bef936c39fad8f16e78e98778b70..cfe0977f9f23c854edf763de406d37c4d6bbccc9 100644 --- a/ipc/native/c/adapter/include/rpc_os_adapter.h +++ b/ipc/native/c/adapter/include/rpc_os_adapter.h @@ -19,17 +19,14 @@ #include #ifdef __cplusplus -#if __cplusplus extern "C" { -#endif #endif /* __cplusplus */ int32_t RpcGetPid(void); int32_t RpcGetUid(void); + #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_OS_ADAPTER_H */ diff --git a/ipc/native/c/ipc/include/ipc_invoker.h b/ipc/native/c/ipc/include/ipc_invoker.h index a254e8f1a25062c6ace2d88698cc793b021a7278..1b5d0b830c5df49d6aa6416044a6e7a0e6ca40f5 100644 --- a/ipc/native/c/ipc/include/ipc_invoker.h +++ b/ipc/native/c/ipc/include/ipc_invoker.h @@ -19,16 +19,12 @@ #include "iremote_invoker.h" #ifdef __cplusplus -#if __cplusplus extern "C" { -#endif #endif /* __cplusplus */ RemoteInvoker *GetIpcInvoker(void); void DeinitIpcInvoker(RemoteInvoker *invoker); #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_INVOKER_H */ \ No newline at end of file diff --git a/ipc/native/c/manager/include/ipc_process_skeleton.h b/ipc/native/c/manager/include/ipc_process_skeleton.h index 9b465aed1b1c4ea9c9461f0aec7215ca97cda1a1..6b0a2c63f9add2d807812c9a678f287cff73ecc6 100644 --- a/ipc/native/c/manager/include/ipc_process_skeleton.h +++ b/ipc/native/c/manager/include/ipc_process_skeleton.h @@ -24,9 +24,7 @@ #include "utils_list.h" #ifdef __cplusplus -#if __cplusplus extern "C" { -#endif #endif /* __cplusplus */ typedef struct { @@ -74,8 +72,6 @@ void WaitForProxyInit(SvcIdentity *svc); int32_t DeleteHandle(int32_t handle); void ResetIpc(void); #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_PROCESS_SKELETON_H */ \ No newline at end of file diff --git a/ipc/native/c/manager/include/ipc_thread_pool.h b/ipc/native/c/manager/include/ipc_thread_pool.h index 5569c380eedea25d57ca779556bab40378a05abe..63bc0173851b65673f1d2d9e547d51970bb083b2 100644 --- a/ipc/native/c/manager/include/ipc_thread_pool.h +++ b/ipc/native/c/manager/include/ipc_thread_pool.h @@ -24,9 +24,7 @@ #include "dbinder_types.h" #ifdef __cplusplus -#if __cplusplus extern "C" { -#endif #endif /* __cplusplus */ enum { @@ -69,8 +67,6 @@ RemoteInvoker *GetRemoteInvoker(void); void UpdateMaxThreadNum(ThreadPool *threadPool, int32_t maxThreadNum); #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_THRREAD_H */ \ No newline at end of file diff --git a/ipc/native/c/manager/include/iremote_invoker.h b/ipc/native/c/manager/include/iremote_invoker.h index 22e8ec6f315588ae242d2e5af2c535c0d5894da2..737b9b99184d164e609490d4b512987c864e5112 100644 --- a/ipc/native/c/manager/include/iremote_invoker.h +++ b/ipc/native/c/manager/include/iremote_invoker.h @@ -21,9 +21,7 @@ #include "serializer.h" #ifdef __cplusplus -#if __cplusplus extern "C" { -#endif #endif /* __cplusplus */ typedef struct { @@ -46,8 +44,6 @@ typedef struct { RemoteInvoker *InitRemoteInvoker(int32_t proto); void DeinitRemoteInvoker(RemoteInvoker *invoker, int32_t proto); #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_IREMOTTE_INVOKER_H */ \ No newline at end of file diff --git a/ipc/native/c/manager/include/rpc_log.h b/ipc/native/c/manager/include/rpc_log.h index 35683a39c8756f932792e5ad2b49f7298e7c6c7f..45fd95b94435ba37cf6cb931e8e509114ab0b100 100644 --- a/ipc/native/c/manager/include/rpc_log.h +++ b/ipc/native/c/manager/include/rpc_log.h @@ -29,10 +29,8 @@ #endif #ifdef __cplusplus -#if __cplusplus extern "C" { #endif -#endif #ifndef IPCRPC_DEBUG #if defined(__LITEOS_M__) @@ -110,8 +108,6 @@ typedef enum { void RpcLog(RpcLogModule module, RpcLogLevel level, const char *fmt, ...); #ifdef __cplusplus -#if __cplusplus } -#endif #endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_LOG_H */ \ No newline at end of file diff --git a/ipc/native/c/manager/include/serializer_inner.h b/ipc/native/c/manager/include/serializer_inner.h index ca281bbca81e1921428fc18236417d1083ffc3db..0dab8ec14e8d7192812a729e9ab382805039d7ab 100644 --- a/ipc/native/c/manager/include/serializer_inner.h +++ b/ipc/native/c/manager/include/serializer_inner.h @@ -19,18 +19,14 @@ #include "serializer.h" #ifdef __cplusplus -#if __cplusplus extern "C" { #endif /* __cplusplus */ -#endif /* __cplusplus */ void *IoPush(IpcIo *io, size_t size); void *IoPop(IpcIo *io, size_t size); #ifdef __cplusplus -#if __cplusplus } #endif /* __cplusplus */ -#endif /* __cplusplus */ #endif /* OHOS_IPC_RPC_SERIALIZER_INNER_H */ diff --git a/ipc/native/c/manager/src/ipc_thread_pool.c b/ipc/native/c/manager/src/ipc_thread_pool.c index 4d6b58327f045d4cefefa98692f169a2d94fd122..c886e3f4e704334707351b88b1ae4b25048bf324 100644 --- a/ipc/native/c/manager/src/ipc_thread_pool.c +++ b/ipc/native/c/manager/src/ipc_thread_pool.c @@ -150,6 +150,12 @@ int32_t SpawnNewThread(ThreadPool *threadPool, int32_t policy, int32_t proto) RPC_LOG_ERROR("get thread pool lock failed."); return ERR_FAILED; } + if (!(proto == IF_PROT_BINDER && threadPool->idleThreadNum > 0) && + !(proto == IF_PROT_DATABUS && threadPool->idleSocketThreadNum > 0)) { + pthread_mutex_unlock(&threadPool->lock); + RPC_LOG_ERROR("thread pool is full."); + return ERR_INVALID_PARAM; + } ThreadContext *threadContext = (ThreadContext *)calloc(1, sizeof(ThreadContext)); if (threadContext == NULL) { pthread_mutex_unlock(&threadPool->lock); @@ -178,15 +184,16 @@ int32_t SpawnNewThread(ThreadPool *threadPool, int32_t policy, int32_t proto) void UpdateMaxThreadNum(ThreadPool *threadPool, int32_t maxThreadNum) { int32_t totalNum = maxThreadNum + maxThreadNum; + if (pthread_mutex_lock(&threadPool->lock) != 0) { + RPC_LOG_ERROR("get thread pool lock failed."); + return; + } int32_t oldThreadNum = threadPool->maxThreadNum; if (totalNum <= oldThreadNum) { + pthread_mutex_unlock(&threadPool->lock); RPC_LOG_ERROR("not support set lower max thread num."); return; } - if (pthread_mutex_lock(&threadPool->lock) != 0) { - RPC_LOG_ERROR("get thread pool lock failed."); - return; - } int32_t diff = totalNum - oldThreadNum; threadPool->maxThreadNum = totalNum; threadPool->idleThreadNum += diff / PROTO_NUM;