Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
b98fb201
Commit
b98fb201
authored
Sep 26, 2018
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix incorrect handling of multiple local commands in a single read.
parent
53518417
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
38 deletions
+41
-38
local.c
local.c
+41
-38
No files found.
local.c
View file @
b98fb201
...
@@ -316,7 +316,7 @@ local_notify_all_1(struct local_socket *s)
...
@@ -316,7 +316,7 @@ local_notify_all_1(struct local_socket *s)
int
int
local_read
(
struct
local_socket
*
s
)
local_read
(
struct
local_socket
*
s
)
{
{
int
rc
;
int
rc
,
n
;
char
*
eol
;
char
*
eol
;
char
reply
[
100
]
=
"ok
\n
"
;
char
reply
[
100
]
=
"ok
\n
"
;
const
char
*
message
=
NULL
;
const
char
*
message
=
NULL
;
...
@@ -336,47 +336,50 @@ local_read(struct local_socket *s)
...
@@ -336,47 +336,50 @@ local_read(struct local_socket *s)
return
rc
;
return
rc
;
s
->
n
+=
rc
;
s
->
n
+=
rc
;
eol
=
memchr
(
s
->
buf
,
'\n'
,
s
->
n
);
while
(
s
->
n
>
0
)
{
if
(
eol
==
NULL
)
eol
=
memchr
(
s
->
buf
,
'\n'
,
s
->
n
);
return
1
;
if
(
eol
==
NULL
)
break
;
n
=
eol
+
1
-
s
->
buf
;
rc
=
parse_config_from_string
(
s
->
buf
,
eol
+
1
-
s
->
buf
,
&
message
);
rc
=
parse_config_from_string
(
s
->
buf
,
n
,
&
message
);
switch
(
rc
)
{
switch
(
rc
)
{
case
CONFIG_ACTION_DONE
:
case
CONFIG_ACTION_DONE
:
break
;
break
;
case
CONFIG_ACTION_QUIT
:
case
CONFIG_ACTION_QUIT
:
shutdown
(
s
->
fd
,
1
);
shutdown
(
s
->
fd
,
1
);
reply
[
0
]
=
'\0'
;
reply
[
0
]
=
'\0'
;
break
;
break
;
case
CONFIG_ACTION_DUMP
:
case
CONFIG_ACTION_DUMP
:
local_notify_all_1
(
s
);
local_notify_all_1
(
s
);
break
;
break
;
case
CONFIG_ACTION_MONITOR
:
case
CONFIG_ACTION_MONITOR
:
local_notify_all_1
(
s
);
local_notify_all_1
(
s
);
s
->
monitor
=
1
;
s
->
monitor
=
1
;
break
;
break
;
case
CONFIG_ACTION_UNMONITOR
:
case
CONFIG_ACTION_UNMONITOR
:
s
->
monitor
=
0
;
s
->
monitor
=
0
;
break
;
break
;
case
CONFIG_ACTION_NO
:
case
CONFIG_ACTION_NO
:
snprintf
(
reply
,
sizeof
(
reply
),
"no%s%s
\n
"
,
snprintf
(
reply
,
sizeof
(
reply
),
"no%s%s
\n
"
,
message
?
" "
:
""
,
message
?
message
:
""
);
message
?
" "
:
""
,
message
?
message
:
""
);
break
;
break
;
default:
default:
snprintf
(
reply
,
sizeof
(
reply
),
"bad
\n
"
);
snprintf
(
reply
,
sizeof
(
reply
),
"bad
\n
"
);
}
}
if
(
reply
[
0
]
!=
'\0'
)
{
if
(
reply
[
0
]
!=
'\0'
)
{
rc
=
write_timeout
(
s
->
fd
,
reply
,
strlen
(
reply
));
rc
=
write_timeout
(
s
->
fd
,
reply
,
strlen
(
reply
));
if
(
rc
<
0
)
if
(
rc
<
0
)
{
goto
fail
;
goto
fail
;
}
}
if
(
s
->
n
>
n
)
memmove
(
s
->
buf
,
s
->
buf
+
n
,
s
->
n
-
n
);
s
->
n
-=
n
;
}
}
if
(
s
->
n
>
eol
+
1
-
s
->
buf
)
{
if
(
s
->
n
==
0
)
{
memmove
(
s
->
buf
,
eol
+
1
,
s
->
n
-
(
eol
+
1
-
s
->
buf
));
s
->
n
-=
(
eol
+
1
-
s
->
buf
);
}
else
{
s
->
n
=
0
;
free
(
s
->
buf
);
free
(
s
->
buf
);
s
->
buf
=
NULL
;
s
->
buf
=
NULL
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment