diff options
| author | Havoc Pennington <hp@redhat.com> | 2007-06-08 20:43:35 +0000 | 
|---|---|---|
| committer | Havoc Pennington <hp@redhat.com> | 2007-06-08 20:43:35 +0000 | 
| commit | 1bd4ecc1256f38d7ab0da736434d46762507348b (patch) | |
| tree | f75bb5a6fe052c261c42e4b42f574dd4e2f4be92 /dbus/dbus-server-socket.c | |
| parent | a579e3b0453dec7b87f15b0021b6ef9d819a12bf (diff) | |
2007-06-08  Havoc Pennington  <hp@redhat.com>
	* backport fix to allow a server to use port=0 or omit port so
	the port can be auto-selected by the OS
Diffstat (limited to 'dbus/dbus-server-socket.c')
| -rw-r--r-- | dbus/dbus-server-socket.c | 9 | 
1 files changed, 5 insertions, 4 deletions
diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index 5c11e145..3a0da35f 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -323,6 +323,9 @@ _dbus_server_new_for_tcp_socket (const char     *host,    if (host == NULL)      host = "localhost"; +   +  listen_fd = _dbus_listen_tcp_socket (host, &port, error); +  _dbus_fd_set_close_on_exec (listen_fd);    _dbus_string_init_const (&host_str, host);    if (!_dbus_string_append (&address, "tcp:host=") || @@ -334,9 +337,7 @@ _dbus_server_new_for_tcp_socket (const char     *host,        dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);        return NULL;      } -   -  listen_fd = _dbus_listen_tcp_socket (host, port, error); -  _dbus_fd_set_close_on_exec (listen_fd); +    if (listen_fd < 0)      { @@ -401,7 +402,7 @@ _dbus_server_listen_socket (DBusAddressEntry *entry,        sresult = _dbus_string_parse_int (&str, 0, &lport, NULL);        _dbus_string_free (&str); -      if (sresult == FALSE || lport <= 0 || lport > 65535) +      if (sresult == FALSE || lport < 0 || lport > 65535)          {            _dbus_set_bad_address(error, NULL, NULL,                                   "Port is not an integer between 0 and 65535");  | 
