diff options
author | monty@tik.mysql.fi <> | 2002-04-17 11:45:26 +0300 |
---|---|---|
committer | monty@tik.mysql.fi <> | 2002-04-17 11:45:26 +0300 |
commit | e29bd611f9bd5018e5d067c4c91870471b261713 (patch) | |
tree | f97bb4563a501314d2d73c2b24eb8510baace522 | |
parent | 7258bf935795183a6e16ef11545c964cae1d79c6 (diff) | |
download | mariadb-git-e29bd611f9bd5018e5d067c4c91870471b261713.tar.gz |
Abort if 'listen()' on TCP/IP fails.
-rw-r--r-- | sql/mysqld.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 16eace54978..ebb7592820b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -917,21 +917,22 @@ static void server_init(void) IPaddr.sin_addr.s_addr = my_bind_addr; IPaddr.sin_port = (unsigned short) htons((unsigned short) mysql_port); (void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg)); - for(;;) + if (bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr), + sizeof(IPaddr)) < 0) { - if (bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr), - sizeof(IPaddr)) >= 0) - break; DBUG_PRINT("error",("Got error: %d from bind",socket_errno)); - sql_perror("Can't start server: Bind on TCP/IP port");/* Had a loop here */ + sql_perror("Can't start server: Bind on TCP/IP port"); sql_print_error("Do you already have another mysqld server running on port: %d ?",mysql_port); unireg_abort(1); } if (listen(ip_sock,(int) back_log) < 0) + { + sql_perror("Can't start server: listen() on TCP/IP port"); sql_print_error("Warning: listen() on TCP/IP failed with error %d", socket_errno); + unireg_abort(1); + } } - if (mysqld_chroot) set_root(mysqld_chroot); |