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
bb5acc93
Commit
bb5acc93
authored
Oct 29, 2009
by
Viliam Mateicka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
httpd: add config option to limit number of clients
parent
bde3d143
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
3 deletions
+31
-3
mpdconf.example
doc/mpdconf.example
+1
-0
user.xml
doc/user.xml
+10
-0
httpd_internal.h
src/output/httpd_internal.h
+6
-0
httpd_output_plugin.c
src/output/httpd_output_plugin.c
+14
-3
No files found.
doc/mpdconf.example
View file @
bb5acc93
...
...
@@ -252,6 +252,7 @@ input {
## quality "5.0" # do not define if bitrate is defined
# bitrate "128" # do not define if quality is defined
# format "44100:16:1"
# max_clients "0" # optional 0=no limit
#}
#
# An example of a pulseaudio output (streaming to a remote pulseaudio server)
...
...
doc/user.xml
View file @
bb5acc93
...
...
@@ -803,6 +803,16 @@ cd mpd-version</programlisting>
second.
</entry>
</row>
<row>
<entry>
<varname>
max_clients
</varname>
<parameter>
MC
</parameter>
</entry>
<entry>
Sets a limit, number of concurrent clients. When set
to 0 no limit will apply.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
...
...
src/output/httpd_internal.h
View file @
bb5acc93
...
...
@@ -97,6 +97,12 @@ struct httpd_output {
* function.
*/
char
buffer
[
32768
];
/**
* The maximum and current number of clients connected
* at the same time.
*/
guint
clients_max
,
clients_cnt
;
};
/**
...
...
src/output/httpd_output_plugin.c
View file @
bb5acc93
...
...
@@ -76,6 +76,8 @@ httpd_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
else
httpd
->
content_type
=
"application/octet-stream"
;
httpd
->
clients_max
=
config_get_block_unsigned
(
param
,
"max_clients"
,
0
);
/* initialize listen address */
sin
=
(
struct
sockaddr_in
*
)
&
httpd
->
address
;
...
...
@@ -124,6 +126,7 @@ httpd_client_add(struct httpd_output *httpd, int fd)
httpd
->
encoder
->
plugin
->
tag
==
NULL
);
httpd
->
clients
=
g_list_prepend
(
httpd
->
clients
,
client
);
httpd
->
clients_cnt
++
;
/* pass metadata to client */
if
(
httpd
->
metadata
)
...
...
@@ -146,10 +149,16 @@ httpd_listen_in_event(G_GNUC_UNUSED GIOChannel *source,
connected */
fd
=
accept
(
httpd
->
fd
,
(
struct
sockaddr
*
)
&
sa
,
&
sa_length
);
if
(
fd
>=
0
)
httpd_client_add
(
httpd
,
fd
);
else
if
(
fd
<
0
&&
errno
!=
EINTR
)
if
(
fd
>=
0
)
{
/* can we allow additional client */
if
(
!
httpd
->
clients_max
||
httpd
->
clients_cnt
<
httpd
->
clients_max
)
httpd_client_add
(
httpd
,
fd
);
else
close
(
fd
);
}
else
if
(
fd
<
0
&&
errno
!=
EINTR
)
{
g_warning
(
"accept() failed: %s"
,
g_strerror
(
errno
));
}
g_mutex_unlock
(
httpd
->
mutex
);
...
...
@@ -237,6 +246,7 @@ httpd_output_open(void *data, struct audio_format *audio_format,
/* initialize other attributes */
httpd
->
clients
=
NULL
;
httpd
->
clients_cnt
=
0
;
httpd
->
timer
=
timer_new
(
audio_format
);
g_mutex_unlock
(
httpd
->
mutex
);
...
...
@@ -281,6 +291,7 @@ httpd_output_remove_client(struct httpd_output *httpd,
assert
(
client
!=
NULL
);
httpd
->
clients
=
g_list_remove
(
httpd
->
clients
,
client
);
httpd
->
clients_cnt
--
;
}
void
...
...
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