Commit Graph

1122 Commits

Author SHA1 Message Date
Thiago de Arruda
796ea333d4 build: Fix error in dispatch generator for functions with channel_id 2014-06-18 11:36:07 -03:00
Thiago de Arruda
0621a6eaa5 events: Refactor how events are queued for processing
To make it possible reuse `event_poll` recursively and in other blocking
function calls, this changes how deferred/immediate events are processed:

- There are two queues in event.c, one for immediate events and another for
  deferred events. The queue used when pushing/processing events is determined
  with boolean arguments passed to `event_push`/`event_process` respectively.
- Events pushed to the immediate queue are processed inside `event_poll` but
  after the `uv_run` call. This is required because libuv event loop does not
  support recursion, and processing events may result in other `event_poll`
  calls.
- Events pushed to the deferred queue are processed later by calling
  `event_process(true)`. This is required to "trick" vim into treating all
  asynchronous events as special keypresses, which is the least obtrusive
  way of introducing asynchronicity into the editor.
- RStream instances will now forward the `defer` flag to the `event_push` call.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
05bf7808e0 events: Refactor event_poll to use stack-allocated timer handles 2014-06-18 11:36:07 -03:00
Thiago de Arruda
4cb5ce3c52 channel: Make channel_{un}subscribe abort the program for invalid ids
These functions will never be called directly by the user so bugs are the only
reason for passing invalid channel ids. Instead of returning silently we abort
to improve bug detection.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
abc423983d job: Refactor job_write to receive WBuffer instances.
This was done to give more control over memory management to job_write callers.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
287967a2c0 job: Add defer flag and setter method
This is has the same effect as the RStream 'defer' flag, but also works for the
job's exit event.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
71d9899f3c job: Refactor to use pointers instead of ids
'job_start' returns the id as an out paramter, and the 'job_find' function is
now used by eval.c to translate job ids into pointers.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
05fd154ede rstream: Implement the rstream_set_defer function
This function will be used to temporarily change the `defer` flag on rstream
instances.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
1843f0c2c6 rstream: Rename RStream async flag to defer
The name `async` was not appropriate to describe the behavior enabled by the
flag.
2014-06-18 11:36:07 -03:00
Thiago de Arruda
ac5fb407e4 wstream: Refactor wstream_new_buffer/wstream_write
- Removed 'copy' parameter from `wstream_new_buffer`. Callers simply pass a
  copy of the buffer if required.
- Added a callback parameter, which is used to notify callers when the data is
  successfully written. The callback is also used to free the buffer(if
  required) and is compatible with `free` from the standard library.
2014-06-18 11:36:04 -03:00
Thiago de Arruda
0c764fb1a4 wstream: Change wstream_write failure behavior
Before this change, any write that could cause a WStream instance to use more
than `maxmem` would fail, which is not acceptable when writing big chunks of
data. (This could happen when returning contents from a big buffer through the
API, for example).

Writes of any size are now allowed, but before we check if the currently used
memory doesn't break the limit. This should be enough to prevent us from
stacking data when talking to a locked process.
2014-06-17 12:12:29 -03:00
Thiago de Arruda
063d8a5773 msgpack_rpc: Deal with deserialization failures
There seems to be no way to deal with failures when calling
`msgpack_unpacker_next`, so this reimplements that function as
`msgpack_rpc_unpack`, which has an additional result for detecting failures.

On top of that, we make use of the new function to properly return msgpack-rpc
errors when something bad happens.
2014-06-17 12:12:29 -03:00
Justin M. Keyes
d199d18159 Merge #787 'removal of redundant OOM error handling' 2014-06-16 20:27:25 -04:00
Felipe Oliveira Carvalho
e85598e5a9 Remove unnecessary comments and unnecessary return 2014-06-16 01:40:29 -03:00
Felipe Oliveira Carvalho
f099809e67 Refator return logic in ses_put_fname() 2014-06-16 01:40:29 -03:00
Felipe Oliveira Carvalho
238fa72884 No OOM for list_alloc() 2014-06-16 01:40:28 -03:00
Felipe Oliveira Carvalho
3cb3c20b74 Fix some "out of memory" comments and few cosmetics 2014-06-16 01:40:28 -03:00
Felipe Oliveira Carvalho
f4002c97dc No OOM in ExpandOldSetting() 2014-06-16 01:40:28 -03:00
Felipe Oliveira Carvalho
b1595e74f2 No OOM in reverse_text() 2014-06-16 01:40:27 -03:00
Felipe Oliveira Carvalho
85100bb01d No OOM in concat_str() (few remaining cases)
Also fixed the duplicated declaration (path.c and strings.c)
2014-06-16 01:40:27 -03:00
Felipe Oliveira Carvalho
3a9a76c996 No OOM in vim_strsave_escape_csi() 2014-06-16 01:36:32 -03:00
Felipe Oliveira Carvalho
a26a1697c7 No OOM in home_replace_save() 2014-06-16 01:36:32 -03:00
Felipe Oliveira Carvalho
cca66742eb No OOM in vim_strsave_fnameescape() 2014-06-16 01:36:31 -03:00
Felipe Oliveira Carvalho
81ca5ff126 No OOM in enc_canonize()
Fix a `return FAIL` that should be `return NULL` in `enc_locale()`
2014-06-16 01:36:31 -03:00
Felipe Oliveira Carvalho
8234f2839f No OOM in vim_strsave_escaped[_ext]() 2014-06-16 01:36:31 -03:00
Felipe Oliveira Carvalho
f7e64c3c5f No OOM in vim_strnsave_up()
And some cleanup in strsave_up()
2014-06-16 01:36:30 -03:00
Felipe Oliveira Carvalho
d0fe14fdfe No OOM in popup_mode_name() 2014-06-16 01:31:37 -03:00
Felipe Oliveira Carvalho
4667fbcbe7 au_get_grouparg() can't fail, remove error handling 2014-06-16 01:31:37 -03:00
Felipe Oliveira Carvalho
3d10e2e0cb No OOM in msg_show_console_dialog() 2014-06-16 01:31:37 -03:00
Felipe Oliveira Carvalho
3b648b0a7b do_map() won't return 4 (OOM) anymore 2014-06-16 01:31:37 -03:00
Felipe Oliveira Carvalho
0b849e775c No OOM in ExpandGeneric() 2014-06-16 01:31:37 -03:00
Felipe Oliveira Carvalho
ab016d3dbd No OOM in expand_shellcmd() 2014-06-16 01:31:36 -03:00
Felipe Oliveira Carvalho
9e7d06da41 No OOM in autoload_name() 2014-06-16 01:31:36 -03:00
Felipe Oliveira Carvalho
bb978fa69c No OOM in save_cmdline_alloc() 2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
129db629dd No OOM in list_insert_tv() and list_extend() 2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
dd57e64794 No OOM in listitem_alloc() 2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
2d092cc229 No OOM in dictitem_copy 2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
48fc1602be No OOM in hash_may_resize() and hash_add_item()
hash_add() can still return FAIL if the key already exists.
2014-06-16 01:31:35 -03:00
Felipe Oliveira Carvalho
6f29364632 No OOM in dictitem_alloc() 2014-06-16 01:31:34 -03:00
Felipe Oliveira Carvalho
c3f88060db No OOM in dict_alloc() and rettv_dict_alloc() 2014-06-16 01:31:34 -03:00
Justin M. Keyes
8bbeb4b480 Merge #743 'Replace vim_strncpy with strlcpy' 2014-06-13 18:09:08 -04:00
Douglas Schneider
d430f039d1 Replace vim_strncpy calls: message.c 2014-06-13 18:08:22 -04:00
Douglas Schneider
1e1750fdce Replace vim_strncpy calls: eval.c 2014-06-13 18:08:22 -04:00
Douglas Schneider
004b45d6f5 Replace vim_strncpy calls: screen.c 2014-06-13 18:08:21 -04:00
Douglas Schneider
03b25f782b Replace vim_strncpy calls: ex_docmd.c 2014-06-13 18:08:21 -04:00
Douglas Schneider
9f4e10b62e Replace vim_strncpy calls: version.c 2014-06-13 18:08:21 -04:00
Douglas Schneider
fe4a7fc7e7 Replace vim_strncpy calls: spell.c 2014-06-13 18:08:21 -04:00
Douglas Schneider
bdf79dd619 Replace vim_strncpy calls: syntax.c 2014-06-13 18:08:21 -04:00
Douglas Schneider
43f5a5ef65 Replace vim_strncpy calls: tag.c 2014-06-13 18:08:21 -04:00
Douglas Schneider
1a1725765c Replace vim_strncpy calls: buffer.c 2014-06-13 18:08:21 -04:00