Author: cazfi Date: Sun Aug 7 07:01:38 2016 New Revision: 33480 URL: http://svn.gna.org/viewcvs/freeciv?rev=33480&view=rev Log: Introduced fc_timeval type
See patch #7558 Modified: branches/S2_5/client/clinet.c branches/S2_5/client/gui-sdl/gui_main.c branches/S2_5/common/connection.c branches/S2_5/server/sernet.c branches/S2_5/utility/netintf.c branches/S2_5/utility/netintf.h branches/S2_5/utility/support.c Modified: branches/S2_5/client/clinet.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/clinet.c?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/client/clinet.c (original) +++ branches/S2_5/client/clinet.c Sun Aug 7 07:01:38 2016 @@ -350,7 +350,7 @@ bool have_data_for_server = (pc->used && pc->send_buffer && 0 < pc->send_buffer->ndata); int n; - struct timeval tv; + fc_timeval tv; tv.tv_sec = 0; tv.tv_usec = 0; Modified: branches/S2_5/client/gui-sdl/gui_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-sdl/gui_main.c?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/client/gui-sdl/gui_main.c (original) +++ branches/S2_5/client/gui-sdl/gui_main.c Sun Aug 7 07:01:38 2016 @@ -524,7 +524,7 @@ Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *pMotionEvent, void *pData)) { Uint16 ID; - static struct timeval tv; + static fc_timeval tv; static fd_set civfdset; Uint32 t_current, t_last_unit_anim, t_last_map_scrolling; Uint32 real_timer_next_call; @@ -538,45 +538,45 @@ /* net check with 10ms delay event loop */ if ((net_socket >= 0) || (ggz_socket >= 0)) { FD_ZERO(&civfdset); - + if (net_socket >= 0) { FD_SET(net_socket, &civfdset); } if (ggz_socket >= 0) { FD_SET(ggz_socket, &civfdset); } - + tv.tv_sec = 0; - tv.tv_usec = 10000;/* 10ms*/ - + tv.tv_usec = 10000; /* 10ms*/ + result = fc_select(MAX(net_socket, ggz_socket) + 1, &civfdset, NULL, NULL, &tv); if (result < 0) { if (errno != EINTR) { - break; + break; } else { - continue; + continue; } } else { if (result > 0) { - if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) { - SDL_PushEvent(pNet_User_Event); - } - if ((ggz_socket >= 0) && FD_ISSET(ggz_socket, &civfdset)) { - SDL_PushEvent(pGGZ_User_Event); - } - } + if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) { + SDL_PushEvent(pNet_User_Event); + } + if ((ggz_socket >= 0) && FD_ISSET(ggz_socket, &civfdset)) { + SDL_PushEvent(pGGZ_User_Event); + } + } } } else { /* if connection is not establish */ SDL_Delay(10); } /* ========================================= */ - + t_current = SDL_GetTicks(); - + if (t_current > real_timer_next_call) { real_timer_next_call = t_current + (real_timer_callback() * 1000); } - + if ((t_current - t_last_unit_anim) > UNITS_TIMER_INTERVAL) { if (autoconnect) { widget_info_counter++; @@ -584,7 +584,7 @@ } else { SDL_PushEvent(pAnim_User_Event); } - + t_last_unit_anim = SDL_GetTicks(); } @@ -596,20 +596,20 @@ } else { t_last_map_scrolling = SDL_GetTicks(); } - + if (widget_info_counter > 0) { SDL_PushEvent(pInfo_User_Event); widget_info_counter = 0; } - + /* ========================================= */ - + if (loop_action) { loop_action(pData); } - + /* ========================================= */ - + while (SDL_PollEvent(&Main.event) == 1) { switch (Main.event.type) { Modified: branches/S2_5/common/connection.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/common/connection.c?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/common/connection.c (original) +++ branches/S2_5/common/connection.c Sun Aug 7 07:01:38 2016 @@ -176,7 +176,7 @@ for (start=0; buf->ndata-start>limit;) { fd_set writefs, exceptfs; - struct timeval tv; + fc_timeval tv; FC_FD_ZERO(&writefs); FC_FD_ZERO(&exceptfs); Modified: branches/S2_5/server/sernet.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/sernet.c?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/server/sernet.c (original) +++ branches/S2_5/server/sernet.c Sun Aug 7 07:01:38 2016 @@ -354,30 +354,32 @@ int i; int max_desc; fd_set writefs, exceptfs; - struct timeval tv; + fc_timeval tv; time_t start; (void) time(&start); for(;;) { tv.tv_sec = (game.server.netwait - (time(NULL) - start)); - tv.tv_usec=0; - - if (tv.tv_sec < 0) + tv.tv_usec = 0; + + if (tv.tv_sec < 0) { return; + } FC_FD_ZERO(&writefs); FC_FD_ZERO(&exceptfs); - max_desc=-1; - - for(i=0; i<MAX_NUM_CONNECTIONS; i++) { + max_desc = -1; + + for (i = 0; i < MAX_NUM_CONNECTIONS; i++) { struct connection *pconn = &connections[i]; + if (pconn->used && !pconn->server.is_closing && 0 < pconn->send_buffer->ndata) { FD_SET(pconn->sock, &writefs); FD_SET(pconn->sock, &exceptfs); - max_desc=MAX(pconn->sock, max_desc); + max_desc = MAX(pconn->sock, max_desc); } } @@ -385,14 +387,15 @@ return; } - if(fc_select(max_desc+1, NULL, &writefs, &exceptfs, &tv)<=0) { + if (fc_select(max_desc + 1, NULL, &writefs, &exceptfs, &tv) <= 0) { return; } - for(i=0; i<MAX_NUM_CONNECTIONS; i++) { /* check for freaky players */ + for (i = 0; i < MAX_NUM_CONNECTIONS; i++) { /* check for freaky players */ struct connection *pconn = &connections[i]; + if (pconn->used && !pconn->server.is_closing) { - if(FD_ISSET(pconn->sock, &exceptfs)) { + if (FD_ISSET(pconn->sock, &exceptfs)) { log_verbose("connection (%s) cut due to exception data", conn_description(pconn)); connection_close_server(pconn, _("network exception")); Modified: branches/S2_5/utility/netintf.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/netintf.c?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/utility/netintf.c (original) +++ branches/S2_5/utility/netintf.c Sun Aug 7 07:01:38 2016 @@ -123,19 +123,19 @@ Wait for a number of sockets to change status **************************************************************/ int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - struct timeval *timeout) + fc_timeval *timeout) { int result; - + result = select(n, readfds, writefds, exceptfds, timeout); - + #ifdef HAVE_WINSOCK if (result == -1) { set_socket_errno(); } #endif /* HAVE_WINSOCK */ - return result; + return result; } /*************************************************************** Modified: branches/S2_5/utility/netintf.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/netintf.h?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/utility/netintf.h (original) +++ branches/S2_5/utility/netintf.h Sun Aug 7 07:01:38 2016 @@ -118,9 +118,11 @@ FC_ADDR_ANY }; +typedef struct timeval fc_timeval; + int fc_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen); int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - struct timeval *timeout); + fc_timeval *timeout); int fc_readsocket(int sock, void *buf, size_t size); int fc_writesocket(int sock, const void *buf, size_t size); void fc_closesocket(int sock); Modified: branches/S2_5/utility/support.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/support.c?rev=33480&r1=33479&r2=33480&view=diff ============================================================================== --- branches/S2_5/utility/support.c (original) +++ branches/S2_5/utility/support.c Sun Aug 7 07:01:38 2016 @@ -483,9 +483,10 @@ #ifdef WIN32_NATIVE Sleep(usec / 1000); #else /* WIN32_NATIVE */ - struct timeval tv; - tv.tv_sec=0; - tv.tv_usec=usec; + fc_timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = usec; /* FIXME: an interrupt can cause an EINTR return here. In that case we * need to have another select call. */ fc_select(0, NULL, NULL, NULL, &tv); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits