From d7613265a1c4947a44f60de7143a6a93287d4fcb Mon Sep 17 00:00:00 2001 From: prabatuty Date: Mon, 4 Jan 2010 05:31:38 +0000 Subject: [PATCH] async server takes 99% cpu because of busywait --- src/tools/csqlasyncserver.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tools/csqlasyncserver.cxx b/src/tools/csqlasyncserver.cxx index 9d4e909e..2df9b2d3 100644 --- a/src/tools/csqlasyncserver.cxx +++ b/src/tools/csqlasyncserver.cxx @@ -225,14 +225,20 @@ void *startThread(void *thrInfo) flag = CSqlAdapter; printDebug(DM_ReplServer, "SqlAdapter Thread created"); AbsCSqlQIterator *iter = thrInput->qIter; - while (1) { if (csqlQ->size()) break; } + struct timeval timeout, tval; + timeout.tv_sec = 5; + while (1) { + if (csqlQ->size()) break; + timeout.tv_sec = 10; + timeout.tv_usec = 0; + os::select(0, 0, 0, 0, &timeout); + } + iter = new ListIter(((ListAsQueue *)csqlQ)->list); AbsSqlConnection *conn = SqlFactory::createConnection(flag); void *stmtBuckets = malloc (STMT_BUCKET_SIZE * sizeof(StmtBucket)); memset(stmtBuckets, 0, STMT_BUCKET_SIZE * sizeof(StmtBucket)); printDebug(DM_ReplServer, "stmtbuckets: %x", stmtBuckets); - struct timeval timeout, tval; - timeout.tv_sec = 0; while (1) { while (1) { rv = conn->connect(I_USER, I_PASS); -- 2.11.4.GIT