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

ASF GitHub Bot commented on DISPATCH-960:
-----------------------------------------

jiridanek commented on a change in pull request #294:
URL: https://github.com/apache/qpid-dispatch/pull/294#discussion_r459886451



##########
File path: src/amqp.c
##########
@@ -90,11 +93,29 @@ const char * const QD_AMQP_COND_CONNECTION_FORCED = 
"amqp:connection:forced";
 const char * const QD_AMQP_PORT_STR = "5672";
 const char * const QD_AMQPS_PORT_STR = "5671";
 
+const char * const QD_AMQP_DFLT_PROTO = "tcp";
+
 int qd_port_int(const char* port_str) {
-    if (!strcmp(port_str, QD_AMQP_PORT_STR)) return QD_AMQP_PORT_INT;
-    if (!strcmp(port_str, QD_AMQPS_PORT_STR)) return QD_AMQPS_PORT_INT;
     errno = 0;
     unsigned long n = strtoul(port_str, NULL, 10);
     if (errno || n > 0xFFFF) return -1;
+
+    // Port is not an integer (port = 'amqp' or 'amqps')
+    if ( !n && strlen(port_str) > 0 ) {
+        // Resolve service port
+        struct servent serv_info;
+        struct servent *serv_info_res;
+        int buf_len = 4096;
+        char *buf = calloc(buf_len, sizeof(char));

Review comment:
       This can be allocated on stack, so `alloca` or `enum {buf_len = 4096 }; 
char buf[buf_len];`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


> TCP port randomly assigned when using 'port: amqp' along with 'http: yes' on 
> a listener
> ---------------------------------------------------------------------------------------
>
>                 Key: DISPATCH-960
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-960
>             Project: Qpid Dispatch
>          Issue Type: Bug
>    Affects Versions: 1.0.1, 1.12.0
>            Reporter: Fernando Giorgetti
>            Priority: Major
>             Fix For: 1.13.0
>
>         Attachments: dispatch-960-reproducer.tar.gz
>
>
> The default configuration for the dispatch router contains a default listener 
> set up to use 'port: amqp'.
> If you change the default listener to use 'http: yes' and starts the router, 
> it causes an issue as the service name (amqp) is not resolved, and so the 
> router attempts to listen to port 0 (random), causing an unpredictable 
> behavior.
>  
> A reproducer is attached to this issue.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to