comparison src/netbeans.c @ 2109:6c3c2e464a96 v7.2.392

updated for version 7.2.392 Problem: Netbeans hangs reading from a socket at the maximum block size. Solution: Use select() or poll(). (Xavier de Gaye)
author Bram Moolenaar <bram@zimbu.org>
date Wed, 10 Mar 2010 16:12:48 +0100
parents 351bf13db807
children e8ef654038c4
comparison
equal deleted inserted replaced
2108:3cdf2a653e00 2109:6c3c2e464a96
734 int len; 734 int len;
735 int readlen = 0; 735 int readlen = 0;
736 #ifndef FEAT_GUI_GTK 736 #ifndef FEAT_GUI_GTK
737 static int level = 0; 737 static int level = 0;
738 #endif 738 #endif
739 #ifdef HAVE_SELECT
740 struct timeval tval;
741 fd_set rfds;
742 #else
743 # ifdef HAVE_POLL
744 struct pollfd fds;
745 # endif
746 #endif
739 747
740 if (sd < 0) 748 if (sd < 0)
741 { 749 {
742 nbdebug(("messageFromNetbeans() called without a socket\n")); 750 nbdebug(("messageFromNetbeans() called without a socket\n"));
743 return; 751 return;
753 buf = alloc(MAXMSGSIZE); 761 buf = alloc(MAXMSGSIZE);
754 if (buf == NULL) 762 if (buf == NULL)
755 return; /* out of memory! */ 763 return; /* out of memory! */
756 } 764 }
757 765
758 /* Keep on reading for as long as there is something to read. */ 766 /* Keep on reading for as long as there is something to read.
767 * Use select() or poll() to avoid blocking on a message that is exactly
768 * MAXMSGSIZE long. */
759 for (;;) 769 for (;;)
760 { 770 {
771 #ifdef HAVE_SELECT
772 FD_ZERO(&rfds);
773 FD_SET(sd, &rfds);
774 tval.tv_sec = 0;
775 tval.tv_usec = 0;
776 if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
777 break;
778 #else
779 # ifdef HAVE_POLL
780 fds.fd = sd;
781 fds.events = POLLIN;
782 if (poll(&fds, 1, 0) <= 0)
783 break;
784 # endif
785 #endif
761 len = sock_read(sd, buf, MAXMSGSIZE); 786 len = sock_read(sd, buf, MAXMSGSIZE);
762 if (len <= 0) 787 if (len <= 0)
763 break; /* error or nothing more to read */ 788 break; /* error or nothing more to read */
764 789
765 /* Store the read message in the queue. */ 790 /* Store the read message in the queue. */