Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
7e0c65b8
Commit
7e0c65b8
authored
8 years ago
by
burneykb
Browse files
Options
Downloads
Patches
Plain Diff
Added remove_client functionality
parent
6ffc61dc
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
groundStation/src/microcart_cli.c
+23
-0
23 additions, 0 deletions
groundStation/src/microcart_cli.c
with
23 additions
and
0 deletions
groundStation/src/microcart_cli.c
+
23
−
0
View file @
7e0c65b8
...
...
@@ -50,6 +50,8 @@ static int new_client(int fd);
static
ssize_t
get_client_index
(
int
fd
);
/* Returns pointer to client buffer, or -1 */
static
char
*
get_client_buffer
(
int
fd
);
/* Returns -1 on error */
static
int
remove_client
(
fd
);
/* Thread-safe wrappers */
pthread_mutex_t
quadSocketMutex
;
...
...
@@ -246,6 +248,15 @@ int main(int argc, char **argv)
}
}
}
}
else
{
for
(
int
i
=
0
;
i
<
MAX_CLIENTS
;
++
i
)
{
if
(
client_fds
[
i
]
!=
-
1
)
{
char
buff
;
if
(
recv
(
client_fds
[
i
],
&
buff
,
1
,
MSG_PEEK
|
MSG_DONTWAIT
)
<
0
)
{
remove_client
(
client_fds
[
i
]);
}
}
}
}
}
...
...
@@ -467,3 +478,15 @@ static char * get_client_buffer(int fd)
return
client_buffers
[
slot
];
}
}
static
int
remove_client
(
fd
)
{
ssize_t
slot
=
get_client_index
(
fd
);
if
(
slot
==
-
1
)
return
slot
;
char
*
clientBuffer
=
get_client_buffer
(
fd
);
if
(
clientBuffer
==
NULL
)
return
-
1
;
clientBuffer
=
'\0'
;
client_fds
[
clientIndex
]
=
-
1
;
return
0
;
}
\ No newline at end of file
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