Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2bc01440
Commit
2bc01440
authored
Jan 03, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: use GLib instead of utils.h
parent
0eb1166b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
client.c
src/client.c
+8
-7
listen.c
src/listen.c
+2
-0
No files found.
src/client.c
View file @
2bc01440
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "conf.h"
#include "conf.h"
#include "listen.h"
#include "listen.h"
#include "permission.h"
#include "permission.h"
#include "utils.h"
#include "event_pipe.h"
#include "event_pipe.h"
#include "dlist.h"
#include "dlist.h"
#include "idle.h"
#include "idle.h"
...
@@ -33,6 +32,9 @@
...
@@ -33,6 +32,9 @@
#include <assert.h>
#include <assert.h>
#include <unistd.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#ifdef WIN32
#ifdef WIN32
#include <ws2tcpip.h>
#include <ws2tcpip.h>
...
@@ -168,7 +170,7 @@ static inline void client_set_expired(struct client *client)
...
@@ -168,7 +170,7 @@ static inline void client_set_expired(struct client *client)
}
}
if
(
client
->
fd
>=
0
)
{
if
(
client
->
fd
>=
0
)
{
x
close
(
client
->
fd
);
close
(
client
->
fd
);
client
->
fd
=
-
1
;
client
->
fd
=
-
1
;
}
}
}
}
...
@@ -187,7 +189,6 @@ static void client_init(struct client *client, int fd)
...
@@ -187,7 +189,6 @@ static void client_init(struct client *client, int fd)
client
->
bufferLength
=
0
;
client
->
bufferLength
=
0
;
client
->
bufferPos
=
0
;
client
->
bufferPos
=
0
;
client
->
fd
=
fd
;
client
->
fd
=
fd
;
set_nonblocking
(
fd
);
client
->
channel
=
g_io_channel_unix_new
(
client
->
fd
);
client
->
channel
=
g_io_channel_unix_new
(
client
->
fd
);
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
client
->
source_id
=
g_io_add_watch
(
client
->
channel
,
G_IO_IN
,
...
@@ -202,7 +203,7 @@ static void client_init(struct client *client, int fd)
...
@@ -202,7 +203,7 @@ static void client_init(struct client *client, int fd)
client
->
permission
=
getDefaultPermissions
();
client
->
permission
=
getDefaultPermissions
();
x
write
(
fd
,
GREETING
,
sizeof
(
GREETING
)
-
1
);
write
(
fd
,
GREETING
,
sizeof
(
GREETING
)
-
1
);
}
}
static
void
free_cmd_list
(
GSList
*
list
)
static
void
free_cmd_list
(
GSList
*
list
)
...
@@ -295,11 +296,11 @@ void client_new(int fd, const struct sockaddr *addr, int uid)
...
@@ -295,11 +296,11 @@ void client_new(int fd, const struct sockaddr *addr, int uid)
if
(
num_clients
>=
client_max_connections
)
{
if
(
num_clients
>=
client_max_connections
)
{
g_warning
(
"Max Connections Reached!"
);
g_warning
(
"Max Connections Reached!"
);
x
close
(
fd
);
close
(
fd
);
return
;
return
;
}
}
client
=
xcalloc
(
1
,
sizeof
(
*
client
)
);
client
=
g_new0
(
struct
client
,
1
);
list_add
(
&
client
->
siblings
,
&
clients
);
list_add
(
&
client
->
siblings
,
&
clients
);
++
num_clients
;
++
num_clients
;
client_init
(
client
,
fd
);
client_init
(
client
,
fd
);
...
@@ -804,7 +805,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args)
...
@@ -804,7 +805,7 @@ void client_vprintf(struct client *client, const char *fmt, va_list args)
/* wtf.. */
/* wtf.. */
return
;
return
;
buffer
=
x
malloc
(
length
+
1
);
buffer
=
g_
malloc
(
length
+
1
);
vsnprintf
(
buffer
,
length
+
1
,
fmt
,
args
);
vsnprintf
(
buffer
,
length
+
1
,
fmt
,
args
);
client_write
(
client
,
buffer
,
length
);
client_write
(
client
,
buffer
,
length
);
free
(
buffer
);
free
(
buffer
);
...
...
src/listen.c
View file @
2bc01440
...
@@ -293,6 +293,8 @@ listen_in_event(G_GNUC_UNUSED GIOChannel *source,
...
@@ -293,6 +293,8 @@ listen_in_event(G_GNUC_UNUSED GIOChannel *source,
fd
=
accept
(
listen_fd
,
&
sockAddr
,
&
socklen
);
fd
=
accept
(
listen_fd
,
&
sockAddr
,
&
socklen
);
if
(
fd
>=
0
)
{
if
(
fd
>=
0
)
{
set_nonblocking
(
fd
);
client_new
(
fd
,
&
sockAddr
,
get_remote_uid
(
fd
));
client_new
(
fd
,
&
sockAddr
,
get_remote_uid
(
fd
));
}
else
if
(
fd
<
0
&&
errno
!=
EINTR
)
{
}
else
if
(
fd
<
0
&&
errno
!=
EINTR
)
{
g_warning
(
"Problems accept()'ing"
);
g_warning
(
"Problems accept()'ing"
);
...
...
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