To: vim_dev@googlegroups.com Subject: Patch 7.4.1814 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1814 Problem: A channel may be garbage collected while it's still being used by a job. (James McCoy) Solution: Mark the channel as used if the job is still used. Do the same for channels that are still used. Files: src/eval.c, src/channel.c, src/proto/channel.pro *** ../vim-7.4.1813/src/eval.c 2016-04-30 18:06:47.114331342 +0200 --- src/eval.c 2016-05-01 13:55:49.258550849 +0200 *************** *** 7024,7029 **** --- 7024,7030 ---- #ifdef FEAT_JOB_CHANNEL abort = abort || set_ref_in_channel(copyID); + abort = abort || set_ref_in_job(copyID); #endif #ifdef FEAT_NETBEANS_INTG abort = abort || set_ref_in_nb_channel(copyID); *** ../vim-7.4.1813/src/channel.c 2016-04-30 17:06:27.167577887 +0200 --- src/channel.c 2016-05-01 14:18:35.802501694 +0200 *************** *** 3553,3580 **** { int abort = FALSE; channel_T *channel; ! int part; for (channel = first_channel; channel != NULL; channel = channel->ch_next) ! { ! for (part = PART_SOCK; part < PART_IN; ++part) { ! jsonq_T *head = &channel->ch_part[part].ch_json_head; ! jsonq_T *item = head->jq_next; ! ! while (item != NULL) ! { ! list_T *l = item->jq_value->vval.v_list; ! ! if (l->lv_copyID != copyID) ! { ! l->lv_copyID = copyID; ! abort = abort || set_ref_in_list(l, copyID, NULL); ! } ! item = item->jq_next; ! } } - } return abort; } --- 3553,3567 ---- { int abort = FALSE; channel_T *channel; ! typval_T tv; for (channel = first_channel; channel != NULL; channel = channel->ch_next) ! if (channel_still_useful(channel)) { ! tv.v_type = VAR_CHANNEL; ! tv.vval.v_channel = channel; ! abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); } return abort; } *************** *** 4092,4097 **** --- 4079,4104 ---- && channel_still_useful(job->jv_channel))); } + /* + * Mark references in jobs that are still useful. + */ + int + set_ref_in_job(int copyID) + { + int abort = FALSE; + job_T *job; + typval_T tv; + + for (job = first_job; job != NULL; job = job->jv_next) + if (job_still_useful(job)) + { + tv.v_type = VAR_JOB; + tv.vval.v_job = job; + abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); + } + return abort; + } + void job_unref(job_T *job) { *** ../vim-7.4.1813/src/proto/channel.pro 2016-04-26 19:01:00.957118797 +0200 --- src/proto/channel.pro 2016-05-01 14:02:55.945529047 +0200 *************** *** 49,54 **** --- 49,55 ---- void free_job_options(jobopt_T *opt); int get_job_options(typval_T *tv, jobopt_T *opt, int supported); channel_T *get_channel_arg(typval_T *tv, int check_open, int reading, int part); + int set_ref_in_job(int copyID); void job_unref(job_T *job); int free_unused_jobs_contents(int copyID, int mask); void free_unused_jobs(int copyID, int mask); *** ../vim-7.4.1813/src/version.c 2016-05-01 13:28:34.517588215 +0200 --- src/version.c 2016-05-01 13:56:54.989776375 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 1814, /**/ -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///