Преглед изворни кода

okay, there is now a native-capable net interface

Zachary Pavlov пре 19 година
родитељ
комит
ad5972e5a3

+ 12 - 3
direct/src/distributed/ConnectionRepository.py

@@ -38,7 +38,7 @@ class ConnectionRepository(
         DoInterestManager.__init__(self)
         DoInterestManager.__init__(self)
         DoCollectionManager.__init__(self)
         DoCollectionManager.__init__(self)
         self.setPythonRepository(self)
         self.setPythonRepository(self)
-
+        
         self.config = config
         self.config = config
 
 
         if hasattr(self, 'setVerbose'):
         if hasattr(self, 'setVerbose'):
@@ -406,8 +406,17 @@ class ConnectionRepository(
             if failureCallback:
             if failureCallback:
                 failureCallback(0, '', *failureArgs)
                 failureCallback(0, '', *failureArgs)
         elif self.connectMethod == self.CM_NATIVE:
         elif self.connectMethod == self.CM_NATIVE:
-            pass
-        
+            for url in serverList:
+                self.notify.info("Connecting to %s via Native interface." % (url.cStr()))
+                if self.connectNative(url):
+                    self.startReaderPollTask()
+                    if successCallback:
+                        successCallback(*successArgs)
+                    return
+
+            # Failed to connect.
+            if failureCallback:
+                failureCallback(0, '', *failureArgs)
     def disconnect(self):
     def disconnect(self):
         """
         """
         Closes the previously-established connection.
         Closes the previously-established connection.

+ 12 - 12
direct/src/distributed/cConnectionRepository.cxx

@@ -54,7 +54,7 @@ CConnectionRepository(bool has_owner_view) :
   _qcr(&_qcm, 0),
   _qcr(&_qcm, 0),
 #endif
 #endif
 #ifdef WANT_NATIVE_NET
 #ifdef WANT_NATIVE_NET
-  _bdc(0,4096000,4096000,102400),
+  _bdc(0,4096000,4096000,1460),
   _native(false),
   _native(false),
 #endif
 #endif
   _client_datagram(true),
   _client_datagram(true),
@@ -157,8 +157,9 @@ connect_native(const URLSpec &url) {
   _native=true;
   _native=true;
   Socket_Address addr;
   Socket_Address addr;
   addr.set_host(url.get_server(),url.get_port());
   addr.set_host(url.get_server(),url.get_port());
+  _bdc.ClearAddresses();
   _bdc.AddAddress(addr);
   _bdc.AddAddress(addr);
-  return _bdc.IsConnected();
+  return _bdc.DoConnect();
 }
 }
 
 
 #endif //WANT NATIVE NET
 #endif //WANT NATIVE NET
@@ -217,8 +218,7 @@ stop_delay() {
 #endif  // SIMULATE_NETWORK_DELAY
 #endif  // SIMULATE_NETWORK_DELAY
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: CConnectionRepository::check_datagram
-//       Access: Published
+//     Function: CConnectionRepository::check_datagram//       Access: Published
 //  Description: Returns true if a new datagram is available, false
 //  Description: Returns true if a new datagram is available, false
 //               otherwise.  If the return value is true, the new
 //               otherwise.  If the return value is true, the new
 //               datagram may be retrieved via get_datagram(), or
 //               datagram may be retrieved via get_datagram(), or
@@ -230,7 +230,11 @@ check_datagram() {
   if (_simulated_disconnect) {
   if (_simulated_disconnect) {
     return false;
     return false;
   }
   }
-  while (do_check_datagram()) {
+  #ifdef WANT_NATIVE_NET
+  if(_native)
+    _bdc.Flush();
+  #endif //WANT_NATIVE_NET
+  while (do_check_datagram()) { //Read a datagram
 #ifndef NDEBUG
 #ifndef NDEBUG
     if (get_verbose()) {
     if (get_verbose()) {
       describe_message(nout, "receive ", _dg.get_message());
       describe_message(nout, "receive ", _dg.get_message());
@@ -407,9 +411,8 @@ consider_flush() {
   }
   }
 
 
 #ifdef WANT_NATIVE_NET
 #ifdef WANT_NATIVE_NET
-  //NATIVENET HERE
   if(_native)
   if(_native)
-    return 1;
+    return true;  //Maybe we should just flush here for now?
 #endif
 #endif
 
 
 #ifdef HAVE_NSPR
 #ifdef HAVE_NSPR
@@ -500,11 +503,7 @@ bool CConnectionRepository::
 do_check_datagram() {
 do_check_datagram() {
   #ifdef WANT_NATIVE_NET
   #ifdef WANT_NATIVE_NET
   if(_native) {
   if(_native) {
-    Datagram * dgi;
-    bool ret= _bdc.GetMessageInternal(&dgi);
-    if(ret)
-      _dg=*dgi;
-    return ret; 
+    return _bdc.GetMessage(_dg);
   }
   }
   #endif
   #endif
   #ifdef HAVE_NSPR
   #ifdef HAVE_NSPR
@@ -711,6 +710,7 @@ void CConnectionRepository::
 describe_message(ostream &out, const string &prefix, 
 describe_message(ostream &out, const string &prefix, 
                  const string &message_data) const {
                  const string &message_data) const {
   DCPacker packer;
   DCPacker packer;
+  
   packer.set_unpack_data(message_data);
   packer.set_unpack_data(message_data);
   CHANNEL_TYPE do_id;
   CHANNEL_TYPE do_id;
   int msg_type;
   int msg_type;