Commit b652a4ff authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by Hiroshi Mimaki

Fixed wrong condition in #4981.

parent 7dc0fe66
...@@ -73,7 +73,7 @@ int socket_available_p; ...@@ -73,7 +73,7 @@ int socket_available_p;
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
static int mrb_io_socket_available() static int mrb_io_socket_available()
{ {
int fd, retval = 1; int fd, retval = 0;
struct sockaddr_un sun0; struct sockaddr_un sun0;
char socketname[] = "tmp.mruby-io-socket-ok.XXXXXXXX"; char socketname[] = "tmp.mruby-io-socket-ok.XXXXXXXX";
if (!(fd = mkstemp(socketname))) { if (!(fd = mkstemp(socketname))) {
...@@ -87,11 +87,10 @@ static int mrb_io_socket_available() ...@@ -87,11 +87,10 @@ static int mrb_io_socket_available()
} }
sun0.sun_family = AF_UNIX; sun0.sun_family = AF_UNIX;
strncpy(sun0.sun_path, socketname, sizeof(sun0.sun_path)); strncpy(sun0.sun_path, socketname, sizeof(sun0.sun_path));
if (bind(fd, (struct sockaddr *)&sun0, sizeof(sun0)) == -1) { if (bind(fd, (struct sockaddr *)&sun0, sizeof(sun0)) == 0) {
retval = 0; retval = 1;
} }
sock_test_out: sock_test_out:
retval = 0;
unlink(socketname); unlink(socketname);
close(fd); close(fd);
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment