From: Cyrill Gorcunov <gorcunov@gmail.com> To: Konstantin Osipov <kostja.osipov@gmail.com> Cc: tml <tarantool-patches@dev.tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v2 1/5] popen: Introduce a backend engine Date: Thu, 26 Dec 2019 10:04:45 +0300 [thread overview] Message-ID: <20191226070445.GC2463@uranus> (raw) In-Reply-To: <20191226043354.GA1337@atlas> On Thu, Dec 26, 2019 at 07:33:54AM +0300, Konstantin Osipov wrote: > > +/** > > + * command_new - allocates a command string from argv array > > Would be nice to say why you need to linearise the command at all > - is it for logging, or error messages, or what? ok > > + * @argv: an array with pointers to argv strings > > + * @nr_argv: number of elements in the @argv > > + * > > + * Returns a new string or NULL on error. > > + */ > > +static inline char * > > +command_new(char **argv, size_t nr_argv) > > _new/_delete are usually used for classes/objects. command is not > a standalone class, so a better name for the function is > alloc_argv or similar. sure, will do > having a separate command_free(0) IMO is over-engineering, as well > as separate handle_free and popen_delete(). I would inline > handle_free() and popen_delete() into popen, as well as > handle_new(). If not, I would at least move all free/destroy > functions close together, so that the code is easier to make ends > of - right now popen_delete() as at the end of a long file, while > command_new/handle_new - at the beginnign. ok, will do > > +ssize_t > > +popen_write(struct popen_handle *handle, void *buf, > > + size_t count, unsigned int flags) > > +{ > > + if (!popen_may_io(handle, STDIN_FILENO, flags)) > > + return -1; > > + > > + if (count > (size_t)SSIZE_MAX) { > > + errno = E2BIG; > > + return -1; > > + } > > + > > + say_debug("popen: %d: write idx [%s:%d] buf %p count %zu", > > + handle->pid, stdX_str(STDIN_FILENO), > > + STDIN_FILENO, buf, count); > > + > > + return write(handle->fds[STDIN_FILENO], buf, count); > > +} > > I think popen_write() should work like follows: > > while (not error and not written the full contents of the buffer) > { > rc = write() > // handle errors > // advance write position > // if written_size != buf_size coio_fiber_yield_timeout() until the descriptor > // becomes ready. > } > > For that to work, the descriptor should be set to non-blocking on > parent side right after fork. > > Why are you allowing a partial write here? Why are you not > accepting an optional timeout? Because it is v2 of the series, which is obsolete. In v6 we already process timeouts. > > > + */ > > +static int > > +popen_wait_read(struct popen_handle *handle, int idx, int timeout_msecs) > > +{ > > + struct pollfd pollfd = { > > + .fd = handle->fds[idx], > > + .events = POLLIN, > > + }; > > + int ret; > > + > > + ret = poll(&pollfd, 1, timeout_msecs); > > Here you block the event loop for timeout_msecs. Why aren't you > using coio_fiber_yield_timeout()? > > The timeout should be in ev_tstamp format, not integer. Already addressed in v6 > popen_read(), similar to popen_write() should be reading the > requested amount or error, not return a partial read. > > > +#else > > + /* FIXME: What about FreeBSD/MachO? > > freebsd has fdsecfs > mac has proc_pidinfo() Thanks a lot for review and this info about freebsd/macho, Kostya! As to fdsecfs/proc_pidinfo -- I simply don't have these machines to test on. I think we will address these platforms on top of the series.
next prev parent reply other threads:[~2019-12-26 7:04 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-10 9:48 [Tarantool-patches] [PATCH v2 0/5] popen: Add ability to run external process Cyrill Gorcunov 2019-12-10 9:48 ` [Tarantool-patches] [PATCH v2 1/5] popen: Introduce a backend engine Cyrill Gorcunov 2019-12-26 4:33 ` Konstantin Osipov 2019-12-26 7:04 ` Cyrill Gorcunov [this message] 2019-12-26 7:12 ` Konstantin Osipov 2019-12-10 9:48 ` [Tarantool-patches] [PATCH v2 2/5] lua/fio: Add lbox_fio_push_error as a separate helper Cyrill Gorcunov 2019-12-10 9:48 ` [Tarantool-patches] [PATCH v2 3/5] popen/fio: Merge popen engine into fio internal module Cyrill Gorcunov 2019-12-10 9:48 ` [Tarantool-patches] [PATCH v2 4/5] popen/fio: Add ability to run external programs Cyrill Gorcunov 2019-12-10 9:48 ` [Tarantool-patches] [PATCH v2 5/5] test: Add app/popen test Cyrill Gorcunov 2019-12-11 9:29 ` [Tarantool-patches] [PATCH v2 0/5] popen: Add ability to run external process Cyrill Gorcunov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191226070445.GC2463@uranus \ --to=gorcunov@gmail.com \ --cc=kostja.osipov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 1/5] popen: Introduce a backend engine' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox