diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-04-14 12:46:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-04-14 12:46:51 +0200 |
commit | ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e (patch) | |
tree | 0b6608049e1b86a10bb179674ed3bf9e41706a15 /src/channel.c | |
parent | 700eefe5a4385fd128f5496e3ca384869752376a (diff) | |
download | vim-git-ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e.tar.gz |
patch 7.4.1727v7.4.1727
Problem: Cannot detect a crash in tests when caused by garbagecollect().
Solution: Add garbagecollect_for_testing(). Do not free a job if is still
useful.
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/channel.c b/src/channel.c index 83d057dbb..72484ecb0 100644 --- a/src/channel.c +++ b/src/channel.c @@ -458,8 +458,7 @@ free_unused_channels(int copyID, int mask) ch_next = ch->ch_next; if ((ch->ch_copyID & mask) != (copyID & mask)) { - /* Free the channel and ordinary items it contains, but don't - * recurse into Lists, Dictionaries etc. */ + /* Free the channel struct itself. */ channel_free_channel(ch); } } @@ -4006,6 +4005,17 @@ job_free(job_T *job) } } +/* + * Return TRUE if the job should not be freed yet. Do not free the job when + * it has not ended yet and there is a "stoponexit" flag or an exit callback. + */ + static int +job_still_useful(job_T *job) +{ + return job->jv_status == JOB_STARTED + && (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL); +} + void job_unref(job_T *job) { @@ -4013,8 +4023,7 @@ job_unref(job_T *job) { /* Do not free the job when it has not ended yet and there is a * "stoponexit" flag or an exit callback. */ - if (job->jv_status != JOB_STARTED - || (job->jv_stoponexit == NULL && job->jv_exit_cb == NULL)) + if (!job_still_useful(job)) { job_free(job); } @@ -4036,7 +4045,8 @@ free_unused_jobs_contents(int copyID, int mask) job_T *job; for (job = first_job; job != NULL; job = job->jv_next) - if ((job->jv_copyID & mask) != (copyID & mask)) + if ((job->jv_copyID & mask) != (copyID & mask) + && !job_still_useful(job)) { /* Free the channel and ordinary items it contains, but don't * recurse into Lists, Dictionaries etc. */ @@ -4055,10 +4065,10 @@ free_unused_jobs(int copyID, int mask) for (job = first_job; job != NULL; job = job_next) { job_next = job->jv_next; - if ((job->jv_copyID & mask) != (copyID & mask)) + if ((job->jv_copyID & mask) != (copyID & mask) + && !job_still_useful(job)) { - /* Free the channel and ordinary items it contains, but don't - * recurse into Lists, Dictionaries etc. */ + /* Free the job struct itself. */ job_free_job(job); } } |