Skip to content

Commit

Permalink
acl_vstream_probe_status maybe be blocked in fiber mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Apr 20, 2017
1 parent 5e271bd commit d91b6f4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib_acl/samples/connect/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char *argv[])
acl_msg_stdout_enable(1);
get_name();
test(argc >= 2 ? argv[1] : "localhost:8809");
return 0;
//return 0;

ACL_VSTREAM *client;
const char *addr;
Expand All @@ -70,18 +70,21 @@ int main(int argc, char *argv[])

addr = argv[1];

acl_msg_stdout_enable(1);
acl_msg_open("connect.log", argv[0]);
printf("connecting %s ...\n", argv[1]);

//acl_poll_prefered(1);
for (int i = 0; i < 10000; i++)
for (int i = 0; i < 1; i++)
{
client = acl_vstream_connect(addr, ACL_BLOCKING, 10, 10, 4096);
if (client == NULL) {
printf("connect %s error(%s)\n", addr, acl_last_serror());
return (1);
}
printf("connect %s ok, %s\n", addr, acl_last_serror());
sleep(1);
ret = acl_vstream_probe_status(client);
printf("connect %s ok, %s, ret=%d\n", addr, acl_last_serror(), ret);
}

printf(">>>>>>connect all ok\r\n");
Expand Down
1 change: 1 addition & 0 deletions lib_acl/samples/server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static void run(const char *addr)
break;
}
printf("accept one client\r\n");
acl_vstream_close(client); continue;
acl_pthread_pool_add(pool, thread_run, client);
}

Expand Down
3 changes: 3 additions & 0 deletions lib_acl/src/stdlib/acl_vstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,9 @@ int acl_vstream_probe_status(ACL_VSTREAM *fp)
return -1;
}

if (acl_read_wait(ACL_VSTREAM_SOCK(fp), 0) < 0)
return errno == ACL_ETIMEDOUT ? 0 : -1;

#ifdef ACL_UNIX
flags = fcntl(ACL_VSTREAM_SOCK(fp), F_GETFL, 0);
if (flags < 0) {
Expand Down
5 changes: 4 additions & 1 deletion lib_acl/src/stdlib/iostuff/acl_read_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ int acl_read_wait(ACL_SOCKET fd, int timeout)
ret = -1;
break;
} else if (ret == 0) {
/*
acl_msg_warn("%s(%d), %s: poll timeout: %s, fd: %d, "
"delay: %d, spent: %ld", __FILE__, __LINE__,
myname, acl_last_serror(), fd, delay,
(long) (time(NULL) - begin));
*/
acl_set_error(ACL_ETIMEDOUT);
ret = -1;
break;
Expand Down Expand Up @@ -433,11 +435,12 @@ int acl_read_wait(ACL_SOCKET fd, int timeout)
acl_last_serror(), (int) fd);
return -1;
case 0:
/*
acl_msg_warn("%s(%d), %s: poll timeout: %s, fd: %d, "
"timeout: %d, spent: %ld", __FILE__, __LINE__,
myname, acl_last_serror(), fd, timeout,
(long) (time(NULL) - begin));

*/
acl_set_error(ACL_ETIMEDOUT);
return -1;
default:
Expand Down
2 changes: 2 additions & 0 deletions lib_acl_cpp/src/db/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,12 @@ const string& query::escape(const char* in, size_t len, string& out)
out += '\\';
out += '\'';
break;
#if 0
case '"': /* Better safe than sorry */
out += '\\';
out += '"';
break;
#endif
case '\032': /* This gives problems on Win32 */
out += '\\';
out += 'Z';
Expand Down

0 comments on commit d91b6f4

Please sign in to comment.