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
5e8f51a9
Commit
5e8f51a9
authored
Jan 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: use the BufferedSocket class for HttpdClient
parent
be3d2188
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
87 deletions
+18
-87
Makefile.am
Makefile.am
+0
-1
ClientNew.cxx
src/ClientNew.cxx
+0
-1
glib_socket.h
src/glib_socket.h
+0
-40
HttpdClient.cxx
src/output/HttpdClient.cxx
+0
-0
HttpdClient.hxx
src/output/HttpdClient.hxx
+17
-44
HttpdOutputPlugin.cxx
src/output/HttpdOutputPlugin.cxx
+1
-1
No files found.
Makefile.am
View file @
5e8f51a9
...
@@ -130,7 +130,6 @@ src_mpd_SOURCES = \
...
@@ -130,7 +130,6 @@ src_mpd_SOURCES = \
src/thread/PosixCond.hxx
\
src/thread/PosixCond.hxx
\
src/thread/WindowsCond.hxx
\
src/thread/WindowsCond.hxx
\
src/thread/GLibCond.hxx
\
src/thread/GLibCond.hxx
\
src/glib_socket.h
\
src/clock.c src/clock.h
\
src/clock.c src/clock.h
\
src/notify.cxx src/notify.hxx
\
src/notify.cxx src/notify.hxx
\
src/audio_config.c src/audio_config.h
\
src/audio_config.c src/audio_config.h
\
...
...
src/ClientNew.cxx
View file @
5e8f51a9
...
@@ -27,7 +27,6 @@ extern "C" {
...
@@ -27,7 +27,6 @@ extern "C" {
#include "resolver.h"
#include "resolver.h"
}
}
#include "Permission.hxx"
#include "Permission.hxx"
#include "glib_socket.h"
#include <assert.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/types.h>
...
...
src/glib_socket.h
deleted
100644 → 0
View file @
be3d2188
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_GLIB_SOCKET_H
#define MPD_GLIB_SOCKET_H
#include <glib.h>
/**
* Portable wrapper for g_io_channel_unix_new() or
* g_io_channel_win32_new_socket().
*/
G_GNUC_MALLOC
static
inline
GIOChannel
*
g_io_channel_new_socket
(
int
fd
)
{
#ifdef G_OS_WIN32
return
g_io_channel_win32_new_socket
(
fd
);
#else
return
g_io_channel_unix_new
(
fd
);
#endif
}
#endif
src/output/HttpdClient.cxx
View file @
5e8f51a9
This diff is collapsed.
Click to expand it.
src/output/HttpdClient.hxx
View file @
5e8f51a9
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#ifndef MPD_OUTPUT_HTTPD_CLIENT_HXX
#ifndef MPD_OUTPUT_HTTPD_CLIENT_HXX
#define MPD_OUTPUT_HTTPD_CLIENT_HXX
#define MPD_OUTPUT_HTTPD_CLIENT_HXX
#include "event/BufferedSocket.hxx"
#include "gcc.h"
#include "gcc.h"
#include <glib.h>
#include <glib.h>
...
@@ -31,37 +32,13 @@
...
@@ -31,37 +32,13 @@
struct
HttpdOutput
;
struct
HttpdOutput
;
class
Page
;
class
Page
;
class
HttpdClient
final
{
class
HttpdClient
final
:
public
BufferedSocket
{
/**
/**
* The httpd output object this client is connected to.
* The httpd output object this client is connected to.
*/
*/
HttpdOutput
*
const
httpd
;
HttpdOutput
*
const
httpd
;
/**
/**
* The TCP socket.
*/
GIOChannel
*
channel
;
/**
* The GLib main loop source id for reading from the socket,
* and to detect errors.
*/
guint
read_source_id
;
/**
* The GLib main loop source id for writing to the socket. If
* 0, then there is no event source currently (because there
* are no queued pages).
*/
guint
write_source_id
;
/**
* For buffered reading. This pointer is only valid while the
* HTTP request is read.
*/
struct
fifo_buffer
*
input
;
/**
* The current state of the client.
* The current state of the client.
*/
*/
enum
{
enum
{
...
@@ -140,7 +117,8 @@ public:
...
@@ -140,7 +117,8 @@ public:
* @param httpd the HTTP output device
* @param httpd the HTTP output device
* @param fd the socket file descriptor
* @param fd the socket file descriptor
*/
*/
HttpdClient
(
HttpdOutput
*
httpd
,
int
_fd
,
bool
_metadata_supported
);
HttpdClient
(
HttpdOutput
*
httpd
,
int
_fd
,
EventLoop
&
_loop
,
bool
_metadata_supported
);
/**
/**
* Note: this does not remove the client from the
* Note: this does not remove the client from the
...
@@ -166,21 +144,6 @@ public:
...
@@ -166,21 +144,6 @@ public:
*/
*/
void
CancelQueue
();
void
CancelQueue
();
bool
Read
();
/**
* Data has been received from the client and it is appended
* to the input buffer.
*/
bool
Received
();
/**
* Check if a complete line of input is present in the input
* buffer, and duplicates it. It is removed from the input
* buffer. The return value has to be freed with g_free().
*/
char
*
ReadLine
();
/**
/**
* Handle a line of the HTTP request.
* Handle a line of the HTTP request.
*/
*/
...
@@ -197,9 +160,12 @@ public:
...
@@ -197,9 +160,12 @@ public:
bool
SendResponse
();
bool
SendResponse
();
gcc_pure
gcc_pure
in
t
GetBytesTillMetaData
()
const
;
ssize_
t
GetBytesTillMetaData
()
const
;
bool
Write
();
ssize_t
TryWritePage
(
const
Page
&
page
,
size_t
position
);
ssize_t
TryWritePageN
(
const
Page
&
page
,
size_t
position
,
ssize_t
n
);
bool
TryWrite
();
/**
/**
* Appends a page to the client's queue.
* Appends a page to the client's queue.
...
@@ -209,7 +175,14 @@ public:
...
@@ -209,7 +175,14 @@ public:
/**
/**
* Sends the passed metadata.
* Sends the passed metadata.
*/
*/
void
PushMetaData
(
Page
*
page
);
void
PushMetaData
(
Page
*
page
);
protected
:
virtual
bool
OnSocketReady
(
unsigned
flags
)
override
;
virtual
InputResult
OnSocketInput
(
const
void
*
data
,
size_t
length
)
override
;
virtual
void
OnSocketError
(
GError
*
error
)
override
;
virtual
void
OnSocketClosed
()
override
;
};
};
#endif
#endif
src/output/HttpdOutputPlugin.cxx
View file @
5e8f51a9
...
@@ -189,7 +189,7 @@ httpd_output_finish(struct audio_output *ao)
...
@@ -189,7 +189,7 @@ httpd_output_finish(struct audio_output *ao)
inline
void
inline
void
HttpdOutput
::
AddClient
(
int
fd
)
HttpdOutput
::
AddClient
(
int
fd
)
{
{
clients
.
emplace_front
(
this
,
fd
,
clients
.
emplace_front
(
this
,
fd
,
GetEventLoop
(),
encoder
->
plugin
->
tag
==
NULL
);
encoder
->
plugin
->
tag
==
NULL
);
++
clients_cnt
;
++
clients_cnt
;
...
...
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