Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6025 in orxonox.OLD


Ignore:
Timestamp:
Dec 10, 2005, 9:07:46 PM (18 years ago)
Author:
rennerc
Message:

fixed some bugs

Location:
branches/network/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_socket.cc

    r5996 r6025  
    2828#include "debug.h"
    2929
     30static SDL_mutex* threadTerminationMutex = SDL_CreateMutex();
    3031
    3132/**
     
    6566  outgoingBufferLength = 0;
    6667
     68#ifdef _USE_OUTGOING_BUFFER
     69  thread_write_running = false;
     70#endif
     71  thread_read_running = false;
     72
    6773  incomingBufferMutex = SDL_CreateMutex();
    6874  outgoingBufferMutex = SDL_CreateMutex();
     75
     76
    6977  socketMutex = SDL_CreateMutex();
    7078  terminateThread = false;
     
    8997 * Default destructor
    9098 */
    91 NetworkSocket::~ NetworkSocket( )
    92 {
     99NetworkSocket::~NetworkSocket( )
     100{
     101  this->terminateThread = true;
    93102  /* Quit SDL_net */
    94103  // NOTE: what if other instances of NetworkSocket running?
     
    275284    if (nbytesread<=0)
    276285    {
    277       printf("SDLNet_TCP_Recv: %s\n", SDLNet_GetError());
     286      if (nbytesread<0)
     287        printf("SDLNet_TCP_Recv: %s\n", SDLNet_GetError());
    278288
    279289      SDL_mutexP(self->socketMutex);
     
    295305  }
    296306
     307  SDL_mutexP(threadTerminationMutex);
     308  self->thread_read_running = false;
     309
     310  if ( !self->thread_write_running )
     311    delete self;
     312  SDL_mutexV(threadTerminationMutex);
     313
     314  printf("QUIT READ THREAD\n");
    297315  return 0;
    298316}
     
    347365  }
    348366
     367  SDL_mutexP(threadTerminationMutex);
     368  self->thread_write_running = false;
     369
     370  if ( !self->thread_read_running )
     371    delete self;
     372  SDL_mutexV(threadTerminationMutex);
     373
    349374  printf("QUIT WRITE THREAD\n");
    350375  return 0;
  • branches/network/src/lib/network/network_socket.h

    r6018 r6025  
    6363  bool terminateThread;
    6464
     65  static SDL_mutex* threadTerminationMutex;
    6566  static int thread_read(void * data);
     67  bool thread_read_running;
    6668#ifdef _USE_OUTGOING_BUFFER
    6769  static int thread_write(void * data);
     70  bool thread_write_running;
    6871#endif
    6972
     
    7477  void init();
    7578
     79  //dont make this public use destroy() instead
     80  ~NetworkSocket();
     81
    7682public:
    7783
     
    7985  NetworkSocket(IPaddress ip);
    8086  NetworkSocket(TCPsocket sock);
    81   ~NetworkSocket();
     87  void destroy() { terminateThread = true; };
     88
    8289
    8390  void connectToServer(IPaddress ip);
  • branches/network/src/lib/network/network_stream.cc

    r6018 r6025  
    9393    {
    9494      (*i)->disconnectServer();
    95       delete *i;
     95      (*i)->destroy();
    9696    }
    9797  }
     
    113113void NetworkStream::processData()
    114114{
    115   printf("processData()");
     115  //PRINTF(0)("processData()\n");
    116116  if ( this->type == NET_SERVER )
    117117    this->updateConnectionList();
     
    188188{
    189189  //check for new connections
     190
    190191  NetworkSocket* tempNetworkSocket = serverSocket->getNewSocket();
    191192
     
    200201    } else
    201202    {
     203      clientId = networkSockets.size();
    202204      networkSockets.push_back(tempNetworkSocket);
    203       clientId = networkSockets.size();
    204     }
    205 
    206     PRINTF(0)("New Client: %s", clientId);
     205    }
     206
     207    PRINTF(0)("New Client: %d\n", clientId);
    207208    //TODO: start handshake
    208209    //new Handshake(true, clientId);
     
    216217    {
    217218      //TODO: tell EntityManager that this player left the game
    218 
    219       delete networkSockets[i];
     219      PRINTF(0)("Client is gone: %d\n", i);
     220
     221      //delete networkSockets[i];
     222      networkSockets[i]->destroy();
    220223      networkSockets[i] = NULL;
    221224
     
    231234  }
    232235
    233 }
     236
     237}
  • branches/network/src/subprojects/network/network_unit_test.cc

    r6018 r6025  
    196196  {
    197197    netMan->synchronize();
    198     SDL_Delay(500);
     198    SDL_Delay(1000);
    199199  }
    200200
Note: See TracChangeset for help on using the changeset viewer.