]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fixed port handling, nonce
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 17 Feb 2007 23:29:37 +0000 (23:29 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 17 Feb 2007 23:29:37 +0000 (23:29 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1108 29311d96-e01e-0410-9327-a35deaab8ce9

branches/riccardo/monitor2/msg/SimpleMessenger.cc
branches/riccardo/monitor2/msg/msg_types.h

index 524a65fe76ce512f2daef511bcac8d46d3378b32..99a04a82918989bbbcc2e1b56b713fee0ce7d983 100644 (file)
@@ -55,7 +55,7 @@ void Rank::sigint()
   lock.Lock();
   derr(0) << "got control-c, exiting" << endl;
   ::close(accepter.listen_sd);
-  exit(-1);
+  _exit(-1);
   lock.Unlock();
 }
 
@@ -84,13 +84,11 @@ int Rank::Accepter::start()
   socklen_t llen = sizeof(rank.listen_addr);
   getsockname(listen_sd, (sockaddr*)&rank.listen_addr, &llen);
   
-  int myport = ntohs(rank.listen_addr.sin_port);
-  dout(10) << "accepter.start bound to port " << myport << endl;
+  dout(10) << "accepter.start bound to " << rank.listen_addr << endl;
 
   // listen!
   rc = ::listen(listen_sd, 1000);
   assert(rc >= 0);
-  //dout(10) << "accepter.start listening on " << myport << endl;
   
   // my address is...  HELP HELP HELP!
   char host[100];
@@ -102,24 +100,20 @@ int Rank::Accepter::start()
 
   // figure out my_addr
   if (g_my_addr.port > 0) {
-    // user specified it, easy.
+    // user specified it, easy peasy.
     rank.my_addr = g_my_addr;
   } else {
-    // try to figure out what ip i can be reached out
-    memset(&rank.listen_addr, 0, sizeof(rank.listen_addr));
-
     // look up my hostname.  blech!  this sucks.
     rank.listen_addr.sin_family = myhostname->h_addrtype;
     memcpy((char *) &rank.listen_addr.sin_addr.s_addr, 
           myhostname->h_addr_list[0], 
           myhostname->h_length);
-    rank.listen_addr.sin_port = htons(myport);
+
+    // set up my_addr with a nonce
     rank.my_addr.set_addr(rank.listen_addr);
+    rank.my_addr.nonce = getpid(); // FIXME: pid might not be best choice here.
   }
-  
-  // set a nonce
-  rank.my_addr.nonce = getpid(); // FIXME: pid might not be best choice here.
-  
+
   dout(10) << "accepter.start my addr is " << rank.my_addr << endl;
 
   // set up signal handler
index 5fd8d780b291eda0ac2d6329b94af0e737f3a4ff..0b92df47020d0d0b7c26afc3b9b3afd75c74c9d7 100644 (file)
@@ -109,12 +109,13 @@ struct entity_addr_t {
 
   void set_addr(tcpaddr_t a) {
     memcpy((char*)ipq, (char*)&a.sin_addr.s_addr, 4);
-    port = a.sin_port;
+    port = ntohs(a.sin_port);
   }
   void make_addr(tcpaddr_t& a) const {
+    memset(&a, 0, sizeof(a));
     a.sin_family = AF_INET;
     memcpy((char*)&a.sin_addr.s_addr, (char*)ipq, 4);
-    a.sin_port = port;
+    a.sin_port = htons(port);
   }
 };