Browse Source

reduce the used CPU when idle

Julius Pfrommer 8 years ago
parent
commit
21e81840c2
2 changed files with 3 additions and 2 deletions
  1. 2 1
      plugins/networklayer_tcp.c
  2. 1 1
      src/server/ua_server_worker.c

+ 2 - 1
plugins/networklayer_tcp.c

@@ -154,6 +154,7 @@ socket_recv(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeou
 #else
     ssize_t ret = recv(connection->sockfd, (char*)response->data, connection->localConf.recvBufferSize, 0);
 #endif
+
     if(ret == 0) {
         /* server has closed the connection */
         UA_ByteString_deleteMembers(response);
@@ -392,7 +393,7 @@ ServerNetworkLayerTCP_getJobs(UA_ServerNetworkLayer *nl, UA_Job **jobs, UA_UInt1
     ServerNetworkLayerTCP *layer = nl->handle;
     fd_set fdset;
     UA_Int32 highestfd = setFDSet(layer, &fdset);
-    struct timeval tmptv = {0, timeout};
+    struct timeval tmptv = {0, timeout * 1000};
     UA_Int32 resultsize;
     resultsize = select(highestfd+1, &fdset, NULL, NULL, &tmptv);
     if(resultsize < 0) {

+ 1 - 1
src/server/ua_server_worker.c

@@ -34,7 +34,7 @@
  * 
  */
 
-#define MAXTIMEOUT 50 // max timeout in millisec until the next main loop iteration
+#define MAXTIMEOUT 500 // max timeout in millisec until the next main loop iteration
 #define BATCHSIZE 20 // max number of jobs that are dispatched at once to workers
 
 static void processJobs(UA_Server *server, UA_Job *jobs, size_t jobsSize) {