Bug 1087213 - Implenent bind function in nsNSSIOLayer. r=honza
authorDragana Damjanovic <dd.mozilla@gmail.com>
Wed, 22 Oct 2014 02:06:00 +0200
changeset 214090 39fb242f5043c288a640059d5e93af941986026c
parent 214089 d3e330ef99c92e3b408c91a825a2fed8eb859c39
child 214091 4845f12212781c8c0ef3e099860c0afe2ec03c97
push id27771
push userryanvm@gmail.com
push dateWed, 05 Nov 2014 19:04:24 +0000
treeherdermozilla-central@305b4fecce99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonza
bugs1087213
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1087213 - Implenent bind function in nsNSSIOLayer. r=honza
security/manager/ssl/src/nsNSSIOLayer.cpp
--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
@@ -1564,16 +1564,26 @@ PSMSend(PRFileDesc* fd, const void* buf,
                                                   flags, timeout);
 
   PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("[%p] wrote %d bytes\n",
          fd, bytesWritten));
 
   return checkHandshake(bytesWritten, false, fd, socketInfo);
 }
 
+static PRStatus
+PSMBind(PRFileDesc* fd, const PRNetAddr *addr)
+{
+  nsNSSShutDownPreventionLock locker;
+  if (!getSocketInfoIfRunning(fd, not_reading_or_writing, locker))
+    return PR_FAILURE;
+
+  return fd->lower->methods->bind(fd->lower, addr);
+}
+
 static int32_t
 nsSSLIOLayerRead(PRFileDesc* fd, void* buf, int32_t amount)
 {
   return PSMRecv(fd, buf, amount, 0, PR_INTERVAL_NO_TIMEOUT);
 }
 
 static int32_t
 nsSSLIOLayerWrite(PRFileDesc* fd, const void* buf, int32_t amount)
@@ -1710,32 +1720,32 @@ nsSSLIOLayerHelpers::Init()
     nsSSLIOLayerMethods.available64 = (PRAvailable64FN) PSMAvailable64;
     nsSSLIOLayerMethods.fsync = (PRFsyncFN) _PSM_InvalidStatus;
     nsSSLIOLayerMethods.seek = (PRSeekFN) _PSM_InvalidInt;
     nsSSLIOLayerMethods.seek64 = (PRSeek64FN) _PSM_InvalidInt64;
     nsSSLIOLayerMethods.fileInfo = (PRFileInfoFN) _PSM_InvalidStatus;
     nsSSLIOLayerMethods.fileInfo64 = (PRFileInfo64FN) _PSM_InvalidStatus;
     nsSSLIOLayerMethods.writev = (PRWritevFN) _PSM_InvalidInt;
     nsSSLIOLayerMethods.accept = (PRAcceptFN) _PSM_InvalidDesc;
-    nsSSLIOLayerMethods.bind = (PRBindFN) _PSM_InvalidStatus;
     nsSSLIOLayerMethods.listen = (PRListenFN) _PSM_InvalidStatus;
     nsSSLIOLayerMethods.shutdown = (PRShutdownFN) _PSM_InvalidStatus;
     nsSSLIOLayerMethods.recvfrom = (PRRecvfromFN) _PSM_InvalidInt;
     nsSSLIOLayerMethods.sendto = (PRSendtoFN) _PSM_InvalidInt;
     nsSSLIOLayerMethods.acceptread = (PRAcceptreadFN) _PSM_InvalidInt;
     nsSSLIOLayerMethods.transmitfile = (PRTransmitfileFN) _PSM_InvalidInt;
     nsSSLIOLayerMethods.sendfile = (PRSendfileFN) _PSM_InvalidInt;
 
     nsSSLIOLayerMethods.getsockname = PSMGetsockname;
     nsSSLIOLayerMethods.getpeername = PSMGetpeername;
     nsSSLIOLayerMethods.getsocketoption = PSMGetsocketoption;
     nsSSLIOLayerMethods.setsocketoption = PSMSetsocketoption;
     nsSSLIOLayerMethods.recv = PSMRecv;
     nsSSLIOLayerMethods.send = PSMSend;
     nsSSLIOLayerMethods.connectcontinue = PSMConnectcontinue;
+    nsSSLIOLayerMethods.bind = PSMBind;
 
     nsSSLIOLayerMethods.connect = nsSSLIOLayerConnect;
     nsSSLIOLayerMethods.close = nsSSLIOLayerClose;
     nsSSLIOLayerMethods.write = nsSSLIOLayerWrite;
     nsSSLIOLayerMethods.read = nsSSLIOLayerRead;
     nsSSLIOLayerMethods.poll = nsSSLIOLayerPoll;
 
     nsSSLPlaintextLayerIdentity = PR_GetUniqueIdentity("Plaintxext PSM layer");