Merge branch 'dev' of feistymeow.org:feisty_meow into dev
[feisty_meow.git] / octopi / library / cromp / cromp_server.cpp
index 2fc7089f709e69e2a290edc3255c409d1f458517..aeafae7a0f54c193af1ed0b9b92d12f76985e8d1 100644 (file)
@@ -128,7 +128,7 @@ public:
     internet_address local_addr = internet_address
         (internet_address::localhost(), client->stack().hostname(), 0);
     open_common(local_addr);  // open the common support for biz.
-    _grabber.start(NIL);  // crank up our background data pump on the socket.
+    _grabber.start(NULL_POINTER);  // crank up our background data pump on the socket.
   }
 
   ~cromp_client_record() {
@@ -182,7 +182,7 @@ public:
   // stops the background activity of this object and drops the connection
   // to the client.
   void croak() {
-//    FUNCDEF("croak");
+    FUNCDEF("croak");
     _grabber.stop();
     int actions = 0;
     while (get_incoming_data(actions)) {
@@ -292,7 +292,7 @@ LOG("cleared out buffer clog.");
     bool saw_something = false;  // true if we got a packet.
     while (actions++ < MAXIMUM_ACTIONS_PER_CLIENT) {
       // pull in anything waiting.
-      infoton *item = NIL;
+      infoton *item = NULL_POINTER;
       octopus_request_id req_id;
       outcome ret = retrieve_and_restore_any(item, req_id,
           first_one? DATA_AWAIT_TIMEOUT : 0);
@@ -450,7 +450,7 @@ public:
     _parent(parent) {}
 
   void perform_activity(void *formal(ptr)) {
-//    FUNCDEF("perform_activity");
+    FUNCDEF("perform_activity");
     _parent.drop_dead_clients(); 
   }
 
@@ -468,7 +468,7 @@ public:
     _parent(parent) {}
 
   void perform_activity(void *formal(ptr)) {
-//    FUNCDEF("perform_activity");
+    FUNCDEF("perform_activity");
     _parent.look_for_clients(*this); 
   }
 
@@ -494,11 +494,11 @@ cromp_server::cromp_server(const internet_address &where,
   _accepting_threads(accepting_threads),
   _dropper(new client_dropping_thread(*this)),
   _enabled(false),
-  _encrypt_arm(NIL),
+  _encrypt_arm(NULL_POINTER),
   _default_security(new cromp_security),
-  _security_arm(NIL)
+  _security_arm(NULL_POINTER)
 {
-//  FUNCDEF("constructor");
+  FUNCDEF("constructor");
 }
  
 cromp_server::~cromp_server()
@@ -511,8 +511,8 @@ cromp_server::~cromp_server()
   WHACK(_where);
   WHACK(_default_security);
   WHACK(_list_lock);
-  _encrypt_arm = NIL;
-  _security_arm = NIL;
+  _encrypt_arm = NULL_POINTER;
+  _security_arm = NULL_POINTER;
 }
 
 internet_address cromp_server::location() const { return *_where; }
@@ -539,7 +539,7 @@ infoton *cromp_server::wrap_infoton(infoton * &request,
     const octopus_entity &ent)
 {
   FUNCDEF("wrap_infoton");
-  if (!_enabled) return NIL;
+  if (!_enabled) return NULL_POINTER;
   // identity is not wrapped with encryption; we need to establish and identity
   // to talk on a distinct channel with the server.  even if that identity were
   // compromised, the interloper should still not be able to listen in on the
@@ -547,7 +547,7 @@ infoton *cromp_server::wrap_infoton(infoton * &request,
   // itself is not encrypted and we don't want to re-encrypt the wrapper.
   if (dynamic_cast<identity_infoton *>(request)
       || dynamic_cast<encryption_infoton *>(request)
-      || dynamic_cast<encryption_wrapper *>(request)) return NIL;
+      || dynamic_cast<encryption_wrapper *>(request)) return NULL_POINTER;
 
 #ifdef DEBUG_CROMP_SERVER
   LOG(astring("encrypting ") + request->text_form());
@@ -557,7 +557,7 @@ infoton *cromp_server::wrap_infoton(infoton * &request,
     // lock here is released a bit down below.
   if (!key) {
     LOG(astring("failed to locate key for entity ") + ent.text_form());
-    return NIL;
+    return NULL_POINTER;
   }
   byte_array packed_request;
   infoton::fast_pack(packed_request, *request);
@@ -604,16 +604,16 @@ outcome cromp_server::enable_servers(bool encrypt, cromp_security *security)
 #endif
   for (int i = 0; i < _accepting_threads; i++) {
     // crank in a new thread and tell it yes on starting it.
-    _accepters->add_thread(new connection_management_thread(*this), true, NIL);
+    _accepters->add_thread(new connection_management_thread(*this), true, NULL_POINTER);
   }
 
-  _dropper->start(NIL);
+  _dropper->start(NULL_POINTER);
   return OKAY;
 }
 
 void cromp_server::disable_servers()
 {
-//  FUNCDEF("disable_servers");
+  FUNCDEF("disable_servers");
   if (!_enabled) return;
   _dropper->stop();  // signal the thread to leave when it can.
   _accepters->stop_all();  // signal the accepting threads to exit.
@@ -648,7 +648,7 @@ int cromp_server::clients() const
 
 bool cromp_server::disconnect_entity(const octopus_entity &id)
 {
-//  FUNCDEF("disconnect_entity");
+  FUNCDEF("disconnect_entity");
   if (!_enabled) return false;
   LOCK_LISTS;
   int indy = _clients->find(id);
@@ -662,7 +662,7 @@ bool cromp_server::disconnect_entity(const octopus_entity &id)
 bool cromp_server::find_entity(const octopus_entity &id,
     internet_address &found)
 {
-//  FUNCDEF("find_entity");
+  FUNCDEF("find_entity");
   if (!_enabled) return false;
   found = internet_address();
   LOCK_LISTS;
@@ -680,7 +680,7 @@ outcome cromp_server::accept_one_client(bool wait)
   FUNCDEF("accept_one_client");
 #endif
   if (!_enabled) return common::INCOMPLETE;
-  spocket *accepted = NIL;
+  spocket *accepted = NULL_POINTER;
 //printf((timestamp(true, true) + "into accept\n").s());
   outcome ret = spock()->accept(accepted, wait);
 //printf((timestamp(true, true) + "out of accept\n").s());
@@ -761,7 +761,7 @@ outcome cromp_server::send_to_client(const octopus_request_id &id,
 outcome cromp_server::get_from_client(const octopus_request_id &id,
     infoton * &data, int timeout)
 {
-//  FUNCDEF("get_from_client");
+  FUNCDEF("get_from_client");
   if (!_enabled) return common::INCOMPLETE;
 //hmmm: this implementation locks the lists; can't we get the client to do
 //      most of the work for this?