Re: [Nrtb-core] [Merge] lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb

2012-04-02 Thread Rick Stovall
Review: Approve

Merge test complete. As there has been no comments or response from the team, 
I'll be moving the code to the alpha stream. We need to be using the 
-std=gnu++0x switch on all compiles and links from this point on.
-- 
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340
Your team NRTB Core is subscribed to branch lp:nrtb.

___
Mailing list: https://launchpad.net/~nrtb-core
Post to : nrtb-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nrtb-core
More help   : https://help.launchpad.net/ListHelp


[Nrtb-core] [Merge] lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb

2012-04-02 Thread Rick Stovall
The proposal to merge lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb has been 
updated.

Status: Needs review = Approved

For more details, see:
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340
-- 
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340
Your team NRTB Core is subscribed to branch lp:nrtb.

___
Mailing list: https://launchpad.net/~nrtb-core
Post to : nrtb-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nrtb-core
More help   : https://help.launchpad.net/ListHelp


[Nrtb-core] [Merge] lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb

2012-04-02 Thread noreply
The proposal to merge lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb has been 
updated.

Status: Approved = Merged

For more details, see:
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340
-- 
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340
Your team NRTB Core is subscribed to branch lp:nrtb.

___
Mailing list: https://launchpad.net/~nrtb-core
Post to : nrtb-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~nrtb-core
More help   : https://help.launchpad.net/ListHelp


[Nrtb-core] [Merge] lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb

2012-04-01 Thread Rick Stovall
Rick Stovall has proposed merging lp:~fpstovall/nrtb/unique_ptr_fix into 
lp:nrtb.

Requested reviews:
  NRTB Core (nrtb-core): code

For more details, see:
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340

First of the changes to bring the code up to C+11 spec, particularly focused on 
replacing boost::shared_ptr with std::unique_ptr where appropriate.

This merge includes significant updates to the sockets and transceiver libs, 
improving stability, reporting and enforcing the logical constraint that a 
socket can have only one owner and that code which accepts a connection from 
the tcp_server socket factory must take actual ownership of the new socket. 
Fixes were also added which allowed the removal of arbitrary time delays in the 
associated unit test programs.

This will be the first of several merges assuming the move to C++11 is 
approved. 
-- 
https://code.launchpad.net/~fpstovall/nrtb/unique_ptr_fix/+merge/100340
Your team NRTB Core is requested to review the proposed merge of 
lp:~fpstovall/nrtb/unique_ptr_fix into lp:nrtb.
=== modified file 'common/sockets/Makefile'
--- common/sockets/Makefile	2011-09-17 01:21:36 +
+++ common/sockets/Makefile	2012-04-01 15:57:19 +
@@ -24,13 +24,13 @@
 
 socket_test:	base_socket.o socket_test.cpp
 	@rm -f socket_test
-	g++ -c -O3 socket_test.cpp -I ../include
-	g++ -o socket_test socket_test.o base_socket.o ../obj/hires_timer.o ../obj/common.o ../obj/base_thread.o -lpthread 
+	g++ -c -O3 socket_test.cpp -I ../include -std=gnu++0x 
+	g++ -o socket_test socket_test.o base_socket.o ../obj/hires_timer.o ../obj/common.o ../obj/base_thread.o -lpthread  -std=gnu++0x
 
 
 base_socket.o:	base_socket.cpp base_socket.h Makefile
 	@rm -f base_socket.o
-	g++ -c -O3 base_socket.cpp -I ../include
+	g++ -c -O3 base_socket.cpp -I ../include -std=gnu++0x 
 
 clean:
 	@rm -vf *.o ../include/base_socket.h socket_test

=== modified file 'common/sockets/base_socket.cpp'
--- common/sockets/base_socket.cpp	2011-09-17 01:21:36 +
+++ common/sockets/base_socket.cpp	2012-04-01 15:57:19 +
@@ -605,32 +605,21 @@
   // take action only if the listen thread is running.
   if (listening())
   {
-	// stop the listener thread
-	if (is_running()) stop();
-	// wait here until the thread stops.
-	if (is_running()) join();
-//	try
-//	{ 
-//	  if (listen_sock) close(listen_sock);
-//	}
-//	catch (...) {};
+// stop the listener thread
+stop();
+join();
   };
 };
 
 bool tcp_server_socket_factory::listening()
 {
-	bool running = is_running();
-/*	if (!running)
-	{
-		// check to be sure the thread did not die due to an error.
-		if (_last_thread_fault != 0)
-		{
-		  // if thread_return was non-zero, it is assumed the thread died an
-		  // evil and useless death. Scream in anger!
-		  throw listen_terminated_exception();
-		};
-	};
-*/	return running;
+  bool running = is_running();
+  return running;
+};
+
+int tcp_server_socket_factory::last_fault()
+{
+  return _last_thread_fault;
 };
 
 unsigned short int tcp_server_socket_factory::backlog()
@@ -643,108 +632,104 @@
 {
   std::cerr  in thread cleanup sock closer  std::endl;
   int  socket = *(static_castint*(sock));
-  ::close(socket);
+  try { ::close(socket); } catch  (...) {};
   std::cerr  socker closer done.  std::endl;
 };
 
 void tcp_server_socket_factory::run()
 {
-  /* Put this entire thing in a try block to protect the application. 
-	* Without this, an untrapped exception thrown here or in the 
-	* user supplied on_accept() method would abort the entire 
-	* application instead of just this
-	* thread.
-	*/
+  // set up the listening socket.
   int listen_sock;
-  // make sure the listener is closed when we exit.
-  pthread_cleanup_push(closeme, (void*) listen_sock);
+  _last_thread_fault = 0;
+  bool go = false;
   try
   {
-	bool go = true;
-	// set up our listening socket.
-	listen_sock = socket(AF_INET,SOCK_STREAM,0);
-	sockaddr_in myaddr;
-	try
-	{
-		myaddr = tcp_socket::str_to_sockaddr(_address);
-	}
-	catch (...)
-	{
-		// probably a tcp_socket::bad_address_exception, 
-		// but any reason will do.
-		go = false;
-	};
-	if (bind(listen_sock,(sockaddr *) myaddr,sizeof(myaddr)))
-	{
-		// bind did not work.
-		go = false;
-	};	
-	if (listen(listen_sock,_backlog))
-	{
-		// listen failed in some way.. I don't care which.
-		go = false;
-	};
-	// processing loop
-	while (go)
-	{
-	  // accept a new connection
-	  bool good_connect = true;
-	  int new_conn = accept(listen_sock,NULL,NULL);
-	  // validate the accept return value.
-	  if (new_conn == -1)
-	  {
-		// accept returned an error.
-		switch (errno) 
-		{
-//			case ENETDOWN :
-			case EPROTO :
-//			case ENOPROTOOPT :
-			case EHOSTDOWN :
-//			case ENONET :
-			case EHOSTUNREACH :
-//			case EOPNOTSUPP :
-//			case ENETUNREACH :
-			case EAGAIN :
-//			case EPERM :
-			case ECONNABORTED :
-{
-  good_connect = false;
-  break;
-};
-			default : 
-{	
-  // for any other error, we're going to shutdown