Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fanout
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
fanout
Commits
c672a0fc
Commit
c672a0fc
authored
11 years ago
by
elliotkendall
Browse files
Options
Downloads
Patches
Plain Diff
Move variable declarations to more specific scopes
parent
547cf242
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fanout.c
+8
-6
8 additions, 6 deletions
fanout.c
with
8 additions
and
6 deletions
fanout.c
+
8
−
6
View file @
c672a0fc
...
@@ -152,7 +152,7 @@ int main (int argc, char *argv[])
...
@@ -152,7 +152,7 @@ int main (int argc, char *argv[])
hints
.
ai_flags
=
AI_PASSIVE
|
AI_ADDRCONFIG
;
hints
.
ai_flags
=
AI_PASSIVE
|
AI_ADDRCONFIG
;
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_socktype
=
SOCK_STREAM
;
int
e
;
int
e
;
int
epollfd
,
nevents
,
efd
,
n
,
res
;
int
epollfd
,
efd
,
n
,
res
;
int
portno
=
1986
;
int
portno
=
1986
;
int
optval
;
int
optval
;
socklen_t
optlen
=
sizeof
(
optval
);
socklen_t
optlen
=
sizeof
(
optval
);
...
@@ -496,6 +496,8 @@ xit\n");
...
@@ -496,6 +496,8 @@ xit\n");
fanout_debug
(
2
,
"max client connections: %d
\n
"
,
client_limit
);
fanout_debug
(
2
,
"max client connections: %d
\n
"
,
client_limit
);
while
(
1
)
{
while
(
1
)
{
int
nevents
;
fanout_debug
(
3
,
"server waiting for new activity
\n
"
);
fanout_debug
(
3
,
"server waiting for new activity
\n
"
);
if
((
nevents
=
epoll_wait
(
epollfd
,
events
,
max_events
,
-
1
))
==
-
1
)
if
((
nevents
=
epoll_wait
(
epollfd
,
events
,
max_events
,
-
1
))
==
-
1
)
...
@@ -695,9 +697,10 @@ char *str_append (char *target, const char *data)
...
@@ -695,9 +697,10 @@ char *str_append (char *target, const char *data)
void
clear_socket_buffer
(
int
sock
)
void
clear_socket_buffer
(
int
sock
)
{
{
int
res
;
char
buffer
[
1025
];
char
buffer
[
1025
];
for
(;;)
{
for
(;;)
{
int
res
;
res
=
read
(
sock
,
buffer
,
1024
);
res
=
read
(
sock
,
buffer
,
1024
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
...
@@ -905,9 +908,9 @@ void remove_client (struct client *c)
...
@@ -905,9 +908,9 @@ void remove_client (struct client *c)
void
shutdown_client
(
struct
client
*
c
)
void
shutdown_client
(
struct
client
*
c
)
{
{
struct
subscription
*
subscription_i
=
subscription_head
;
struct
subscription
*
subscription_i
=
subscription_head
;
struct
subscription
*
subscription_tmp
;
while
(
subscription_i
!=
NULL
)
{
while
(
subscription_i
!=
NULL
)
{
struct
subscription
*
subscription_tmp
;
subscription_tmp
=
subscription_i
;
subscription_tmp
=
subscription_i
;
subscription_i
=
subscription_i
->
next
;
subscription_i
=
subscription_i
->
next
;
if
(
c
==
subscription_tmp
->
client
)
if
(
c
==
subscription_tmp
->
client
)
...
@@ -936,11 +939,10 @@ void destroy_client (struct client *c)
...
@@ -936,11 +939,10 @@ void destroy_client (struct client *c)
void
client_write
(
struct
client
*
c
,
const
char
*
data
)
void
client_write
(
struct
client
*
c
,
const
char
*
data
)
{
{
int
sent
;
c
->
output_buffer
=
str_append
(
c
->
output_buffer
,
data
);
c
->
output_buffer
=
str_append
(
c
->
output_buffer
,
data
);
while
(
strlen
(
c
->
output_buffer
)
>
0
)
{
while
(
strlen
(
c
->
output_buffer
)
>
0
)
{
int
sent
;
sent
=
send
(
c
->
fd
,
c
->
output_buffer
,
strlen
(
c
->
output_buffer
),
sent
=
send
(
c
->
fd
,
c
->
output_buffer
,
strlen
(
c
->
output_buffer
),
MSG_NOSIGNAL
);
MSG_NOSIGNAL
);
if
(
sent
==
-
1
)
if
(
sent
==
-
1
)
...
@@ -956,7 +958,6 @@ void client_write (struct client *c, const char *data)
...
@@ -956,7 +958,6 @@ void client_write (struct client *c, const char *data)
void
client_process_input_buffer
(
struct
client
*
c
)
void
client_process_input_buffer
(
struct
client
*
c
)
{
{
char
*
line
;
char
*
message
;
char
*
message
;
char
*
action
;
char
*
action
;
char
*
channel
;
char
*
channel
;
...
@@ -965,6 +966,7 @@ void client_process_input_buffer (struct client *c)
...
@@ -965,6 +966,7 @@ void client_process_input_buffer (struct client *c)
fanout_debug
(
3
,
"full buffer
\n\n
%s
\n\n
"
,
c
->
input_buffer
);
fanout_debug
(
3
,
"full buffer
\n\n
%s
\n\n
"
,
c
->
input_buffer
);
while
((
i
=
strcpos
(
c
->
input_buffer
,
'\n'
))
>=
0
)
{
while
((
i
=
strcpos
(
c
->
input_buffer
,
'\n'
))
>=
0
)
{
char
*
line
;
line
=
substr
(
c
->
input_buffer
,
0
,
i
-
1
);
line
=
substr
(
c
->
input_buffer
,
0
,
i
-
1
);
fanout_debug
(
3
,
"buffer has a newline at char %d
\n
"
,
i
);
fanout_debug
(
3
,
"buffer has a newline at char %d
\n
"
,
i
);
fanout_debug
(
3
,
"line is %d chars: %s
\n
"
,
(
u_int
)
strlen
(
line
),
line
);
fanout_debug
(
3
,
"line is %d chars: %s
\n
"
,
(
u_int
)
strlen
(
line
),
line
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment