Commit Graph

22 Commits

Author SHA1 Message Date
oni-link
dba8433723 Try to fix problem found in the Travis Ci build.
An uv_pipe_t handle for a WStream could be left open for a
particular code path.

Patch by tarruda.
2014-11-09 10:35:39 +01:00
Thiago de Arruda
d4f032a133 wstream: Memory allocation improvements
- Rename WriteData to WRequest
- Inline uv_write_t into WRequest, avoiding an extra allocation
- Manage WBuffer/WRequest instances using klib memory pools
2014-11-02 16:47:50 -03:00
Thiago de Arruda
45525853d3 wstream/shell: Fix memory errors caused by os_system
The os_system function uses a write callback to close the input stream when the
write completes, but this causes a memory error because the callback is invoked
right before the stream is freed by the caller.

This fixes the problem by removing the callback set by os_system. Instead, it
calls job_close_in immediately after writing(the stream will only close after
the write completes). The 'pending' parameter was also removed from the
'write_cb' as it should be hidden by the wstream module.

While the `wstream_set_write_cb` and `job_write_cb` are no longer used, they
will remain in the codebase for future use.
2014-10-01 21:42:00 -03:00
Thiago de Arruda
03f4d17fc9 wstream: Fix close/free
The current code was leading to an invalid free when the wstream was closed
2014-09-12 13:25:28 -03:00
Thiago de Arruda
801ed0e0a3 wstream: Implement wstream_set_file
It's analogous to rstream_set_file but only supports pipes(Support for regular
files may be added later). This function was added to support creating API
channels via stdout.
2014-08-28 14:17:58 -03:00
Nicolas Hillegeer
891b4b9d2b wstream: allow empty release wbuffer cb
Sometimes a wbuffer is not supposed to be free()'d (such as when it comes
from a constant (possibly static) string, for example.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
06cc046e30 wstream: write completion callback
Now modules using the wstream can find out what's happening to their writes.
2014-07-27 14:00:44 -03:00
Thiago de Arruda
0e20afe37e wstream: Pass WBuffer refcount as a constructor parameter
This is required to handle broadcasting when the first write fails.

Ref: 11916b6b59 (commitcomment-6792287)
2014-07-17 11:30:01 -03:00
Thiago de Arruda
5d9c73ce70 wstream: document default value for 'maxmem' 2014-07-17 11:30:01 -03:00
Brandon Coleman
e69cfa6c15 move assert.h include out of vim.h 2014-07-09 00:18:19 +02:00
Thiago de Arruda
c722e22ee6 wstream: Make wstream_write consider the return value from uv_write 2014-06-24 13:02:23 -03:00
Thiago de Arruda
30fc6a4fd1 wstream: Use a default value of 10mb for maxmem when 0 is passed 2014-06-24 13:02:23 -03:00
Thiago de Arruda
11916b6b59 wstream: Refactor buffer memory management
- Extract code to release WBuffer instances into `release_wbuffer`
- Fix memory leak when wstream_write returns false
2014-06-24 13:02:23 -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
ZyX
dca28e55c7 Fix some styles 2014-06-02 11:04:18 -03:00
ZyX
70929f7e16 Add automatic generation of headers
- The 'stripdecls.py' script replaces declarations in all headers by includes to
  generated headers.
  `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'`
  was used for this.
- Add and integrate gendeclarations.lua into the build system to generate the
  required includes.
- Add -Wno-unused-function
- Made a bunch of old-style definitions ANSI

This adds a requirement: all type and structure definitions must be present
before INCLUDE_GENERATED_DECLARATIONS-protected include.

Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is
the only exception.
2014-06-02 11:04:17 -03:00
ZyX
880957ad4e Move documentation from function declarations to definitions
Uses a perl script to move it (scripts/movedocs.pl)
2014-06-02 11:04:04 -03:00
Thiago de Arruda
09bcd97023 WStream: Refactor: Use reference count for memory management
Now `wstream_write` receives pointers for WBuffer objects(created with
wstream_new_buffer), which stores a reference count to determine when it's safe
the free the buffer. This was done to enable writing of the same buffer to
multiple WStream instances
2014-05-28 08:52:54 -03:00
Thiago de Arruda
1c308e28f1 Refactor: Use size_t for {w,r}streams.c 2014-05-28 08:52:54 -03:00
Eliseo Martínez
409cc138f2 Introduce nvim namespace: Fix project-local includes.
Prepend 'nvim/' in all project-local (non-system) includes.
2014-05-15 20:46:01 +02:00
Eliseo Martínez
da51dc9cf2 Introduce nvim namespace: Move files.
Move files from src/ to src/nvim/.
- src/nvim/ becomes the new root dir for nvim executable sources.
- src/libnvim/ is planned to become root dir of the neovim library.
2014-05-15 20:46:01 +02:00