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
308b3f23
Commit
308b3f23
authored
Sep 24, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listen: handle fatal errors with GError
Don't call g_error(), which will abort the process and dump core.
parent
1e561079
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
10 deletions
+29
-10
listen.c
src/listen.c
+15
-8
listen.h
src/listen.h
+6
-1
main.c
src/main.c
+8
-1
No files found.
src/listen.c
View file @
308b3f23
...
@@ -347,7 +347,8 @@ listen_add_config_param(unsigned int port,
...
@@ -347,7 +347,8 @@ listen_add_config_param(unsigned int port,
}
}
}
}
void
listen_global_init
(
void
)
bool
listen_global_init
(
GError
**
error_r
)
{
{
int
port
=
config_get_positive
(
CONF_PORT
,
DEFAULT_PORT
);
int
port
=
config_get_positive
(
CONF_PORT
,
DEFAULT_PORT
);
const
struct
config_param
*
param
=
const
struct
config_param
*
param
=
...
@@ -361,10 +362,12 @@ void listen_global_init(void)
...
@@ -361,10 +362,12 @@ void listen_global_init(void)
do
{
do
{
success
=
listen_add_config_param
(
port
,
param
,
&
error
);
success
=
listen_add_config_param
(
port
,
param
,
&
error
);
if
(
!
success
)
if
(
!
success
)
{
g_error
(
"Failed to listen on %s (line %i): %s"
,
g_propagate_prefixed_error
(
error_r
,
error
,
param
->
value
,
param
->
line
,
"Failed to listen on %s (line %i): "
,
error
->
message
);
param
->
value
,
param
->
line
);
return
false
;
}
param
=
config_get_next_param
(
CONF_BIND_TO_ADDRESS
,
param
=
config_get_next_param
(
CONF_BIND_TO_ADDRESS
,
param
);
param
);
...
@@ -374,12 +377,16 @@ void listen_global_init(void)
...
@@ -374,12 +377,16 @@ void listen_global_init(void)
configured port on all interfaces */
configured port on all interfaces */
success
=
listen_add_port
(
port
,
&
error
);
success
=
listen_add_port
(
port
,
&
error
);
if
(
!
success
)
if
(
!
success
)
{
g_error
(
"Failed to listen on *:%d: %s"
,
g_propagate_prefixed_error
(
error_r
,
error
,
port
,
error
->
message
);
"Failed to listen on *:%d: "
,
port
);
return
false
;
}
}
}
listen_port
=
port
;
listen_port
=
port
;
return
true
;
}
}
void
listen_global_finish
(
void
)
void
listen_global_finish
(
void
)
...
...
src/listen.h
View file @
308b3f23
...
@@ -20,9 +20,14 @@
...
@@ -20,9 +20,14 @@
#ifndef MPD_LISTEN_H
#ifndef MPD_LISTEN_H
#define MPD_LISTEN_H
#define MPD_LISTEN_H
#include <glib.h>
#include <stdbool.h>
extern
int
listen_port
;
extern
int
listen_port
;
void
listen_global_init
(
void
);
bool
listen_global_init
(
GError
**
error_r
);
void
listen_global_finish
(
void
);
void
listen_global_finish
(
void
);
...
...
src/main.c
View file @
308b3f23
...
@@ -273,6 +273,8 @@ int main(int argc, char *argv[])
...
@@ -273,6 +273,8 @@ int main(int argc, char *argv[])
struct
options
options
;
struct
options
options
;
clock_t
start
;
clock_t
start
;
bool
create_db
;
bool
create_db
;
GError
*
error
=
NULL
;
bool
success
;
daemonize_close_stdin
();
daemonize_close_stdin
();
...
@@ -301,7 +303,12 @@ int main(int argc, char *argv[])
...
@@ -301,7 +303,12 @@ int main(int argc, char *argv[])
tag_lib_init
();
tag_lib_init
();
log_init
(
options
.
verbose
,
options
.
log_stderr
);
log_init
(
options
.
verbose
,
options
.
log_stderr
);
listen_global_init
();
success
=
listen_global_init
(
&
error
);
if
(
!
success
)
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
return
EXIT_FAILURE
;
}
daemonize_set_user
();
daemonize_set_user
();
...
...
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