comparison src/channel.c @ 12443:579faede5d9c v8.0.1101

patch 8.0.1101: channel write fails if writing to log fails commit https://github.com/vim/vim/commit/71eeb74a608ddae2b52fb43766616672d0cdda18 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 13 22:18:01 2017 +0200 patch 8.0.1101: channel write fails if writing to log fails Problem: Channel write fails if writing to log fails. Solution: Ignore return value of fwrite(). (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2081)
author Christian Brabandt <cb@256bit.org>
date Wed, 13 Sep 2017 22:30:05 +0200
parents e9dbdc4d8279
children f28067b83dec
comparison
equal deleted inserted replaced
12442:3ba53234ccf3 12443:579faede5d9c
136 { 136 {
137 return log_fd != NULL; 137 return log_fd != NULL;
138 } 138 }
139 139
140 static void 140 static void
141 ch_log_lead(char *what, channel_T *ch) 141 ch_log_lead(const char *what, channel_T *ch)
142 { 142 {
143 if (log_fd != NULL) 143 if (log_fd != NULL)
144 { 144 {
145 #ifdef FEAT_RELTIME 145 #ifdef FEAT_RELTIME
146 proftime_T log_now; 146 proftime_T log_now;
1811 else 1811 else
1812 head->rq_prev->rq_next = node; 1812 head->rq_prev->rq_next = node;
1813 head->rq_prev = node; 1813 head->rq_prev = node;
1814 } 1814 }
1815 1815
1816 if (log_fd != NULL && lead != NULL) 1816 if (ch_log_active() && lead != NULL)
1817 { 1817 {
1818 ch_log_lead(lead, channel); 1818 ch_log_lead(lead, channel);
1819 fprintf(log_fd, "'"); 1819 fprintf(log_fd, "'");
1820 if (fwrite(buf, len, 1, log_fd) != 1) 1820 ignored = (int)fwrite(buf, len, 1, log_fd);
1821 return FAIL;
1822 fprintf(log_fd, "'\n"); 1821 fprintf(log_fd, "'\n");
1823 } 1822 }
1824 return OK; 1823 return OK;
1825 } 1824 }
1826 1825
3383 * buffer. */ 3382 * buffer. */
3384 msg = vim_strnsave(buf, (int)(nl - buf)); 3383 msg = vim_strnsave(buf, (int)(nl - buf));
3385 channel_consume(channel, part, (int)(nl - buf) + 1); 3384 channel_consume(channel, part, (int)(nl - buf) + 1);
3386 } 3385 }
3387 } 3386 }
3388 if (log_fd != NULL) 3387 if (ch_log_active())
3389 ch_log(channel, "Returning %d bytes", (int)STRLEN(msg)); 3388 ch_log(channel, "Returning %d bytes", (int)STRLEN(msg));
3390 return msg; 3389 return msg;
3391 } 3390 }
3392 3391
3393 /* 3392 /*
3668 } 3667 }
3669 channel->ch_error = TRUE; 3668 channel->ch_error = TRUE;
3670 return FAIL; 3669 return FAIL;
3671 } 3670 }
3672 3671
3673 if (log_fd != NULL) 3672 if (ch_log_active())
3674 { 3673 {
3675 ch_log_lead("SEND ", channel); 3674 ch_log_lead("SEND ", channel);
3676 fprintf(log_fd, "'"); 3675 fprintf(log_fd, "'");
3677 ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd); 3676 ignored = (int)fwrite(buf_arg, len_arg, 1, log_fd);
3678 fprintf(log_fd, "'\n"); 3677 fprintf(log_fd, "'\n");