qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [qpid-dispatch] jiridanek commented on a change in pull request #294: DISPATCH-960 - Resolving service port when using http listener
Date Thu, 23 Jul 2020 10:09:31 GMT

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



##########
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));
+
+        // Service port is resolved
+        if ( !getservbyname_r(port_str, QD_AMQP_DFLT_PROTO, &serv_info, buf, buf_len,
&serv_info_res) ) {

Review comment:
       Also, `getservbyname_r` is unavailable on macOS, there `getservbyname` is already reentrant.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


Mime
View raw message