[ 
https://issues.apache.org/jira/browse/COUCHDB-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13411547#comment-13411547
 ] 

Dave Cottlehuber commented on COUCHDB-1512:
-------------------------------------------

Here's a patch that should address it, error & stack trace now looks like this 
for [httpd] bind_address = foo.bar

BindAddress is invalid: foo.bar
[error] [<0.97.0>] {error_report,<0.35.0>,
                       {<0.97.0>,supervisor_report,
                        [{supervisor,{local,couch_secondary_services}},
                         {errorContext,start_error},
                         {reason,invalid_bind_address},

Andrew what platform was this on and how was CouchDB started? I don't get the 
hung VM that you report, just a straight exit + stacktrace.

diff --git i/src/couchdb/couch_httpd.erl w/src/couchdb/couch_httpd.erl
index 7329c3b..a494178 100644
--- i/src/couchdb/couch_httpd.erl
+++ w/src/couchdb/couch_httpd.erl
@@ -97,6 +97,14 @@ start_link(Name, Options) ->
     % will restart us and then we will pick up the new settings.
 
     BindAddress = couch_config:get("httpd", "bind_address", any),
+    % ensure BindAddress is not symbolic hostname. Fixes COUCHDB-1512.
+    case inet_parse:address(BindAddress) of
+        {ok, _BindAddress} -> BindAddress;
+        _ ->
+            io:format("BindAddress is invalid: ~s~n", [BindAddress]),
+            throw({error, invalid_bind_address})
+    end,
+
     DefaultSpec = "{couch_httpd_db, handle_request}",
     DefaultFun = make_arity_1_fun(
         couch_config:get("httpd", "default_handler", DefaultSpec)

#1 I assume it's OK to use inet_parse:address even though it's not specifically 
documented, but is referred to in www.erlang.org/doc/man/inet.html

#2 It seems during start_link/2 we only return errors via io:format rather than 
?LOG macros. Is there a good reason for that?

                
> Provide proper error if a hostname (and not an ip) is used for bind_address
> ---------------------------------------------------------------------------
>
>                 Key: COUCHDB-1512
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1512
>             Project: CouchDB
>          Issue Type: Improvement
>            Reporter: Andrew Melo
>            Assignee: Dave Cottlehuber
>            Priority: Minor
>
> Currently, couch throws an opaque error message and doesn't bind the tcp 
> port, but the process doesn't die, so it's unclear what's happening. 
> Preferably, couch should raise an informative error message and die if an 
> invalid bind_address is passed

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to