Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
oai
freediameter
Commits
9433279d
Commit
9433279d
authored
Dec 14, 2010
by
Sebastien Decugis
Browse files
Improvements to usability, still work ongoing
parent
674afad8
Changes
2
Hide whitespace changes
Inline
Side-by-side
freeDiameter/main.c
View file @
9433279d
...
...
@@ -45,6 +45,7 @@ static void fd_shutdown(int signal);
static
int
main_cmdline
(
int
argc
,
char
*
argv
[]);
static
void
main_version
(
void
);
static
void
main_help
(
void
);
static
int
signal_framework_ready
(
void
);
/* The static configuration structure */
static
struct
fd_config
conf
;
...
...
@@ -117,6 +118,7 @@ int main(int argc, char * argv[])
/* Now, just wait for events */
TRACE_DEBUG
(
INFO
,
FD_PROJECT_BINARY
" daemon initialized."
);
CHECK_FCT
(
signal_framework_ready
()
);
while
(
1
)
{
int
code
;
size_t
sz
;
void
*
data
;
CHECK_FCT_DO
(
fd_event_get
(
fd_g_config
->
cnf_main_ev
,
&
code
,
&
sz
,
&
data
),
break
);
...
...
@@ -349,3 +351,30 @@ static void fd_shutdown(int signal)
return
;
}
/* Signal extensions when the framework is completly initialized */
static
int
is_ready
=
0
;
static
pthread_mutex_t
is_ready_mtx
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_cond_t
is_ready_cnd
=
PTHREAD_COND_INITIALIZER
;
static
int
signal_framework_ready
(
void
)
{
TRACE_ENTRY
(
""
);
CHECK_POSIX
(
pthread_mutex_lock
(
&
is_ready_mtx
)
);
is_ready
=
1
;
CHECK_POSIX
(
pthread_cond_broadcast
(
&
is_ready_cnd
)
);
CHECK_POSIX
(
pthread_mutex_unlock
(
&
is_ready_mtx
)
);
return
0
;
}
int
fd_wait_initialization_complete
(
void
)
{
TRACE_ENTRY
(
""
);
CHECK_POSIX
(
pthread_mutex_lock
(
&
is_ready_mtx
)
);
pthread_cleanup_push
(
fd_cleanup_mutex
,
&
is_ready_mtx
);
while
(
!
is_ready
)
{
CHECK_POSIX
(
pthread_cond_wait
(
&
is_ready_cnd
,
&
is_ready_mtx
)
);
}
pthread_cleanup_pop
(
0
);
CHECK_POSIX
(
pthread_mutex_unlock
(
&
is_ready_mtx
)
);
return
0
;
}
include/freeDiameter/freeDiameter.h
View file @
9433279d
...
...
@@ -675,6 +675,17 @@ void fd_event_destroy(struct fifo **queue, void (*free_cb)(void * data));
const
char
*
fd_ev_str
(
int
event
);
/* The following function does not really use events, but it may be used
by extensions that need to start an action when the framework is fully initialized.
This function will block until all initializations are performed in the daemon.
It is meant to be used as follow by extensions:
- in initialization callback, create a new thread.
- this new thread calls this function.
- when the function returns, the thread can start working and using all framework features.
*/
int
fd_wait_initialization_complete
(
void
);
/***************************************/
/* Endpoints lists helpers */
/***************************************/
...
...
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