Parcourir la source

epoll init

master
Krzysztof Kwiatkowski il y a 10 ans
Parent
révision
aea977d6ea
13 fichiers modifiés avec 371147 ajouts et 21 suppressions
  1. +1
    -0
      withepoll/Makefile
  2. +0
    -0
      withselect/Makefile
  3. +0
    -0
      withselect/README.md
  4. +7
    -4
      withselect/client.cpp
  5. +0
    -0
      withselect/client.h
  6. +1
    -1
      withselect/defs.h
  7. +0
    -0
      withselect/etc/cert
  8. +0
    -0
      withselect/etc/pkey
  9. +371114
    -0
      withselect/out
  10. +24
    -16
      withselect/server.cpp
  11. +0
    -0
      withselect/server.h
  12. +0
    -0
      withselect/ssl_process.cpp
  13. +0
    -0
      withselect/ssl_process.h

+ 1
- 0
withepoll/Makefile Voir le fichier

@@ -0,0 +1 @@


Makefile → withselect/Makefile Voir le fichier


README.md → withselect/README.md Voir le fichier


client.cpp → withselect/client.cpp Voir le fichier

@@ -103,14 +103,18 @@ void Client::receive()
memset(buf,'\0',MAX_PACKET_SIZE);
int len_rcv = 0;
{
bool flag = true;
while( flag )
bool flag = 1;
while( flag )
{
lock_guard<mutex> lock(WriteReadMutex);
// cout << "SSL_read: start" << endl;
len_rcv = SSL_read(SSLHandler, buf, MAX_PACKET_SIZE);
// cout << "SSL_read: stop" << endl;
flag = handle_error_code(len_rcv, SSLHandler, len_rcv, "SSL_read");
if( !flag )
flag = SSL_pending(SSLHandler);
cout << "PENDING: " << flag << endl;

}
}

@@ -223,8 +227,7 @@ void Client::renegotiate()
exit(1);
}
}

// cout << "SSL State: " << SSL_state_string(SSLHandler) << endl;
cout << "SSL State: " << SSL_state_string(SSLHandler) << endl;
// if(SSL_do_handshake(SSLHandler) <= 0){
// cerr << "SSL_do_handshake() failed. STATE: "
// << SSL_state_string(SSLHandler) << endl;

client.h → withselect/client.h Voir le fichier


defs.h → withselect/defs.h Voir le fichier

@@ -1,5 +1,5 @@
#define MAX_PACKET_SIZE 1024
#define PORT 1420
#define PORT 5061
#define IP "127.0.0.1"
#define EXCHANGE_STRING "ABCDEFGHIJKLMNOPRSTUWXYZ"
#define EXCHANGE_STRING_LEN sizeof(EXCHANGE_STRING)/sizeof(EXCHANGE_STRING[0])

etc/cert → withselect/etc/cert Voir le fichier


etc/pkey → withselect/etc/pkey Voir le fichier


+ 371114
- 0
withselect/out
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


server.cpp → withselect/server.cpp Voir le fichier

@@ -268,27 +268,35 @@ void Receive()
cout << SSL_state_string(handler.second) << endl;
{
lock_guard<mutex> lock(WriteReadMutex);
cout << "SSL_read: start" << endl;
len_rcv = SSL_read(handler.second, buf, 1024);
// cout << "SSL_read: stop" << endl;
if( !handle_error_code(len_rcv, handler.second, len_rcv, "rcv") )
int flag = 1;
while( flag!=0 )
{
// dirty thing - if it has \n on the end - remove it
if( buf[len_rcv-1] == '\n' )
buf[len_rcv-1] = '\0';
cout << "SSL_read: start" << endl;
len_rcv = SSL_read(handler.second, buf, 1024);
flag = SSL_pending(handler.second);
cout << "PENDING: " << flag << endl;
cout << buf << endl;
// cout << "SSL_read: stop" << endl;
if( !handle_error_code(len_rcv, handler.second, len_rcv, "rcv") )
{
// add it back to the socket so that select can use it
lock_guard<mutex> guard(SocketSetMutex);
SocketSet.insert(handler);
// push handler ID and notify sender thread
WriteHandler = handler;
WaitForWrite.notify_one();
// dirty thing - if it has \n on the end - remove it
if( buf[len_rcv-1] == '\n' )
buf[len_rcv-1] = '\0';
cout << buf << endl;
{
// add it back to the socket so that select can use it
lock_guard<mutex> guard(SocketSetMutex);
SocketSet.insert(handler);
// push handler ID and notify sender thread
WriteHandler = handler;
WaitForWrite.notify_one();
}
break;
}
break;
}
}
}
}

server.h → withselect/server.h Voir le fichier


ssl_process.cpp → withselect/ssl_process.cpp Voir le fichier


ssl_process.h → withselect/ssl_process.h Voir le fichier


Chargement…
Annuler
Enregistrer