home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.060 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  5.2 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.060
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.060
  11. Problem:    Netbeans: crash when socket is disconnected unexpectedly.
  12. Solution:   Don't cleanup when a read fails, put a message in the queue and
  13.         disconnect later. (Xavier de Gaye)
  14. Files:        src/netbeans.c
  15.  
  16.  
  17. *** ../vim-7.3.059/src/netbeans.c    2010-11-16 15:04:51.000000000 +0100
  18. --- src/netbeans.c    2010-11-16 15:48:36.000000000 +0100
  19. ***************
  20. *** 135,148 ****
  21.   static int needupdate = 0;
  22.   static int inAtomic = 0;
  23.   
  24.       static void
  25. ! netbeans_close(void)
  26.   {
  27. -     if (!NETBEANS_OPEN)
  28. -     return;
  29. -     netbeans_send_disconnect();
  30.   #ifdef FEAT_GUI_X11
  31.       if (inputHandler != (XtInputId)NULL)
  32.       {
  33. --- 135,146 ----
  34.   static int needupdate = 0;
  35.   static int inAtomic = 0;
  36.   
  37. + /*
  38. +  * Close the socket and remove the input handlers.
  39. +  */
  40.       static void
  41. ! nb_close_socket(void)
  42.   {
  43.   #ifdef FEAT_GUI_X11
  44.       if (inputHandler != (XtInputId)NULL)
  45.       {
  46. ***************
  47. *** 167,179 ****
  48.   # endif
  49.   #endif
  50.   
  51.   #ifdef FEAT_BEVAL
  52.       bevalServers &= ~BEVAL_NETBEANS;
  53.   #endif
  54.   
  55. -     sock_close(nbsock);
  56. -     nbsock = -1;
  57.       needupdate = 0;
  58.       inAtomic = 0;
  59.       nb_free();
  60. --- 165,191 ----
  61.   # endif
  62.   #endif
  63.   
  64. +     sock_close(nbsock);
  65. +     nbsock = -1;
  66. + }
  67. + /*
  68. +  * Close the connection and cleanup.
  69. +  * May be called when nb_close_socket() was called earlier.
  70. +  */
  71. +     static void
  72. + netbeans_close(void)
  73. + {
  74. +     if (NETBEANS_OPEN)
  75. +     {
  76. +     netbeans_send_disconnect();
  77. +     nb_close_socket();
  78. +     }
  79.   #ifdef FEAT_BEVAL
  80.       bevalServers &= ~BEVAL_NETBEANS;
  81.   #endif
  82.   
  83.       needupdate = 0;
  84.       inAtomic = 0;
  85.       nb_free();
  86. ***************
  87. *** 632,640 ****
  88.       char_u    *p;
  89.       queue_T    *node;
  90.   
  91. -     if (!NETBEANS_OPEN)
  92. -     return;
  93.       while (head.next != NULL && head.next != &head)
  94.       {
  95.       node = head.next;
  96. --- 644,649 ----
  97. ***************
  98. *** 720,725 ****
  99. --- 729,736 ----
  100.   }
  101.   #endif
  102.   
  103. + #define DETACH_MSG "DETACH\n"
  104.       void
  105.   netbeans_read()
  106.   {
  107. ***************
  108. *** 780,801 ****
  109.           break;    /* did read everything that's available */
  110.       }
  111.   
  112.       if (readlen <= 0)
  113.       {
  114. !     /* read error or didn't read anything */
  115. !     netbeans_close();
  116. !     nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
  117.       if (len < 0)
  118.       {
  119.           nbdebug(("read from Netbeans socket\n"));
  120.           PERROR(_("read from Netbeans socket"));
  121.       }
  122. -     return; /* don't try to parse it */
  123.       }
  124.   
  125.   #if defined(NB_HAS_GUI) && defined(FEAT_GUI_GTK)
  126.       if (NB_HAS_GUI && gtk_main_level() > 0)
  127. !         gtk_main_quit();
  128.   #endif
  129.   }
  130.   
  131. --- 791,822 ----
  132.           break;    /* did read everything that's available */
  133.       }
  134.   
  135. +     /* Reading a socket disconnection (readlen == 0), or a socket error. */
  136.       if (readlen <= 0)
  137.       {
  138. !     /* Queue a "DETACH" netbeans message in the command queue in order to
  139. !      * terminate the netbeans session later. Do not end the session here
  140. !      * directly as we may be running in the context of a call to
  141. !      * netbeans_parse_messages():
  142. !      *    netbeans_parse_messages
  143. !      *        -> autocmd triggered while processing the netbeans cmd
  144. !      *        -> ui_breakcheck
  145. !      *            -> gui event loop or select loop
  146. !      *            -> netbeans_read()
  147. !      */
  148. !     save((char_u *)DETACH_MSG, strlen(DETACH_MSG));
  149. !     nb_close_socket();
  150.       if (len < 0)
  151.       {
  152.           nbdebug(("read from Netbeans socket\n"));
  153.           PERROR(_("read from Netbeans socket"));
  154.       }
  155.       }
  156.   
  157.   #if defined(NB_HAS_GUI) && defined(FEAT_GUI_GTK)
  158.       if (NB_HAS_GUI && gtk_main_level() > 0)
  159. !     gtk_main_quit();
  160.   #endif
  161.   }
  162.   
  163. ***************
  164. *** 1164,1169 ****
  165. --- 1185,1194 ----
  166.   
  167.       nbdebug(("REP %d: <none>\n", cmdno));
  168.   
  169. +     /* Avoid printing an annoying error message. */
  170. +     if (!NETBEANS_OPEN)
  171. +     return;
  172.       sprintf(reply, "%d\n", cmdno);
  173.       nb_send(reply, "nb_reply_nil");
  174.   }
  175. ***************
  176. *** 2753,2763 ****
  177.   {
  178.   #ifdef FEAT_GUI
  179.   # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK)  \
  180. !                 && !defined(FEAT_GUI_W32)
  181.       if (gui.in_use)
  182.       {
  183. !         EMSG(_("E838: netbeans is not supported with this GUI"));
  184. !         return;
  185.       }
  186.   # endif
  187.   #endif
  188. --- 2778,2788 ----
  189.   {
  190.   #ifdef FEAT_GUI
  191.   # if !defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK)  \
  192. !         && !defined(FEAT_GUI_W32)
  193.       if (gui.in_use)
  194.       {
  195. !     EMSG(_("E838: netbeans is not supported with this GUI"));
  196. !     return;
  197.       }
  198.   # endif
  199.   #endif
  200. *** ../vim-7.3.059/src/version.c    2010-11-16 15:04:51.000000000 +0100
  201. --- src/version.c    2010-11-16 15:22:39.000000000 +0100
  202. ***************
  203. *** 716,717 ****
  204. --- 716,719 ----
  205.   {   /* Add new patch number below this line */
  206. + /**/
  207. +     60,
  208.   /**/
  209.  
  210. -- 
  211.    Another bucket of what can only be described as human ordure hits ARTHUR.
  212. ARTHUR: ... Right!  (to the KNIGHTS) That settles it!
  213.                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
  214.  
  215.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  216. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  217. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  218.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  219.