[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 03/07: comm: Buffer the communication socket on the client si
From: |
Ludovic Courtès |
Subject: |
[shepherd] 03/07: comm: Buffer the communication socket on the client side. |
Date: |
Wed, 27 Jan 2016 14:00:24 +0000 |
civodul pushed a commit to branch master
in repository shepherd.
commit 8b8f503cdd1a110125d06784c6e41e14db86c803
Author: Ludovic Courtès <address@hidden>
Date: Wed Jan 27 14:27:16 2016 +0100
comm: Buffer the communication socket on the client side.
* modules/shepherd/comm.scm (open-connection): Add 'setvbuf' call.
(write-command): Add 'force-output' call.
---
modules/shepherd/comm.scm | 8 ++++++--
modules/shepherd/scripts/herd.scm | 7 ++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/modules/shepherd/comm.scm b/modules/shepherd/comm.scm
index 07d47bb..7590171 100644
--- a/modules/shepherd/comm.scm
+++ b/modules/shepherd/comm.scm
@@ -77,7 +77,8 @@ return the socket."
(address (make-socket-address PF_UNIX file)))
(catch 'system-error
(lambda ()
- (connect sock address))
+ (connect sock address)
+ (setvbuf sock _IOFBF 1024))
(lambda (key proc format-string format-args errno . rest)
;; Guile's 'connect' throws an exception that doesn't specify
;; FILE. Augment it with this information.
@@ -116,7 +117,10 @@ wrong---premature end-of-file, invalid sexp, etc."
(service ,service)
(arguments ,arguments)
(directory ,directory))
- port))))
+ port)
+
+ ;; PORT may be buffered so make sure the command goes out.
+ (force-output port))))
;; Replies to commands.
diff --git a/modules/shepherd/scripts/herd.scm
b/modules/shepherd/scripts/herd.scm
index 55265ca..98e2c7f 100644
--- a/modules/shepherd/scripts/herd.scm
+++ b/modules/shepherd/scripts/herd.scm
@@ -96,11 +96,8 @@ the daemon via SOCKET-FILE."
(write-command (shepherd-command action* service #:arguments args)
sock)
- ;; Receive output.
- (setvbuf sock _IOLBF)
-
- ;; Interpret the command's output when possible and format it in a
- ;; human-readable way.
+ ;; Receive output. Interpret the command's output when possible and
+ ;; format it in a human-readable way.
(match (read sock)
(('reply ('version 0 _ ...) ;no errors
('result result) ('error #f)
- [shepherd] branch master updated (83567c4 -> bc7757c), Ludovic Courtès, 2016/01/27
- [shepherd] 01/07: build: Really make sure installed .go files are newer., Ludovic Courtès, 2016/01/27
- [shepherd] 04/07: comm: Buffer the communication socket on the server side., Ludovic Courtès, 2016/01/27
- [shepherd] 03/07: comm: Buffer the communication socket on the client side.,
Ludovic Courtès <=
- [shepherd] 06/07: doc: Improve the introduction., Ludovic Courtès, 2016/01/27
- [shepherd] 07/07: Update 'NEWS'., Ludovic Courtès, 2016/01/27
- [shepherd] 02/07: comm: The 'arguments' of a command is a list., Ludovic Courtès, 2016/01/27
- [shepherd] 05/07: doc: Document the sexp protocol., Ludovic Courtès, 2016/01/27