update to set fd handler flags

SVN revision: 52909
This commit is contained in:
Mike Blumenkrantz 2010-09-29 23:50:33 +00:00
parent e6aa360c21
commit d82f8c771e
1 changed files with 9 additions and 2 deletions

View File

@ -10,8 +10,10 @@
/* Ecore_Fd_Handler example /* Ecore_Fd_Handler example
* 2010 Mike Blumenkrantz * 2010 Mike Blumenkrantz
* compile with gcc $(pkgconfig --cflags --libs gnutls ecore)
*/ */
#define print(...) fprintf(stderr, "line %i: ", __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n") #define print(...) fprintf(stderr, "line %i: ", __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
static int done = 0; static int done = 0;
@ -103,12 +105,17 @@ static Eina_Bool
_process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler) _process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler)
{ {
static int ret, lastret; static int ret, lastret;
static unsigned int count = 0;
if (!done) if (!done)
{ {
lastret = ret; lastret = ret;
print("calling gnutls_handshake()");
ret = gnutls_handshake (client); ret = gnutls_handshake (client);
count++;
if (gnutls_record_get_direction(client))
ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_WRITE);
else
ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_READ);
/* avoid printing messages infinity times */ /* avoid printing messages infinity times */
if (lastret != ret) if (lastret != ret)
{ {
@ -129,7 +136,7 @@ _process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler)
if (ret == GNUTLS_E_SUCCESS) if (ret == GNUTLS_E_SUCCESS)
{ {
done = 1; done = 1;
print("Handshake successful!"); print("Handshake successful in %u handshake calls!", count);
ecore_main_loop_quit(); ecore_main_loop_quit();
} }