Merge lp:~clint-fewbar/gearmand/listen-only-once into lp:gearmand/1.0

Proposed by Clint Byrum on 2012-01-18
Status: Merged
Merge reported by: Brian Aker
Merged at revision: not available
Proposed branch: lp:~clint-fewbar/gearmand/listen-only-once
Merge into: lp:gearmand/1.0
Diff against target: 26 lines (+9/-0)
1 file modified
libgearman-server/gearmand.cc (+9/-0)
To merge this branch: bzr merge lp:~clint-fewbar/gearmand/listen-only-once
Reviewer Review Type Date Requested Status
Gearman-developers 2012-01-18 Pending
Review via email: mp+88991@code.launchpad.net

Description of the change

Not sure if this is the optimal way to handle the bug, but it does seem very straightforward and solves the given test case.

To post a comment you must log in.
482. By Clint Byrum on 2012-01-19

remove unnecessary unordered_map include

483. By Clint Byrum on 2012-01-19

revert accidental change to ltmain.sh

484. By Clint Byrum on 2012-01-19

revert accidental change to ltversion.m4

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgearman-server/gearmand.cc'
2--- libgearman-server/gearmand.cc 2012-01-18 01:41:28 +0000
3+++ libgearman-server/gearmand.cc 2012-01-19 18:43:27 +0000
4@@ -392,6 +392,8 @@
5 return GEARMAN_ERRNO;
6 }
7
8+ std::set<std::string> unique_hosts;
9+
10 for (struct addrinfo *addrinfo_next= addrinfo; addrinfo_next != NULL;
11 addrinfo_next= addrinfo_next->ai_next)
12 {
13@@ -408,6 +410,13 @@
14 strcpy(port->port, "-");
15 }
16
17+ std::string hstring(host);
18+
19+ if (unique_hosts.find(hstring) != unique_hosts.end()) {
20+ gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Already listening on %s", host);
21+ continue;
22+ }
23+ unique_hosts.insert(hstring);
24 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "Trying to listen on %s:%s", host, port->port);
25
26 /* Call to socket() can fail for some getaddrinfo results, try another. */

Subscribers

People subscribed via source and target branches