Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
debf7d33
Commit
debf7d33
authored
Apr 11, 2011
by
Marek Vavrusa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated error codes comments, cleanup of server.
Removed synchronous zone loading, now fully async. Commit refs
#583
.
parent
60fada5a
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
152 additions
and
217 deletions
+152
-217
src/dnslib/zone-load.h
src/dnslib/zone-load.h
+2
-2
src/knot/conf/conf.c
src/knot/conf/conf.c
+4
-0
src/knot/conf/conf.h
src/knot/conf/conf.h
+9
-8
src/knot/conf/logconf.h
src/knot/conf/logconf.h
+3
-2
src/knot/ctl/process.h
src/knot/ctl/process.h
+12
-8
src/knot/main.c
src/knot/main.c
+8
-18
src/knot/other/error.c
src/knot/other/error.c
+1
-2
src/knot/other/error.h
src/knot/other/error.h
+1
-2
src/knot/other/log.c
src/knot/other/log.c
+1
-2
src/knot/other/log.h
src/knot/other/log.h
+15
-16
src/knot/server/dthreads.c
src/knot/server/dthreads.c
+3
-3
src/knot/server/dthreads.h
src/knot/server/dthreads.h
+39
-31
src/knot/server/name-server.h
src/knot/server/name-server.h
+6
-2
src/knot/server/server.c
src/knot/server/server.c
+1
-85
src/knot/server/server.h
src/knot/server/server.h
+11
-13
src/knot/server/socket.c
src/knot/server/socket.c
+4
-4
src/knot/server/socket.h
src/knot/server/socket.h
+24
-11
src/knot/server/tcp-handler.h
src/knot/server/tcp-handler.h
+2
-2
src/knot/server/udp-handler.c
src/knot/server/udp-handler.c
+1
-1
src/knot/server/udp-handler.h
src/knot/server/udp-handler.h
+2
-2
src/tests/knot/server_tests.c
src/tests/knot/server_tests.c
+3
-3
No files found.
src/dnslib/zone-load.h
View file @
debf7d33
...
...
@@ -52,8 +52,8 @@ dnslib_zone_t *dnslib_zload_load(zloader_t *loader);
*
* \param loader Zone loader instance.
*
* \retval
True
is if needs to be recompiled.
* \retval
False
if it is up to date.
* \retval
1
is if needs to be recompiled.
* \retval
0
if it is up to date.
*/
int
dnslib_zload_needs_update
(
zloader_t
*
loader
);
...
...
src/knot/conf/conf.c
View file @
debf7d33
...
...
@@ -419,6 +419,10 @@ int conf_add_hook(conf_t * conf, int sections,
int
(
*
on_update
)(
const
conf_t
*
,
void
*
),
void
*
data
)
{
conf_hook_t
*
hook
=
malloc
(
sizeof
(
conf_hook_t
));
if
(
!
hook
)
{
return
KNOT_ENOMEM
;
}
hook
->
sections
=
sections
;
hook
->
update
=
on_update
;
hook
->
data
=
data
;
...
...
src/knot/conf/conf.h
View file @
debf7d33
...
...
@@ -186,8 +186,8 @@ conf_t *conf_new(const char* path);
* \param on_update Callback.
* \param data User specified data for hook.
*
* \retval
0 on success (EOK)
.
* \retval
<0 on error ()
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_ENOMEM out of memory error
.
*/
int
conf_add_hook
(
conf_t
*
conf
,
int
sections
,
int
(
*
on_update
)(
const
conf_t
*
,
void
*
),
void
*
data
);
...
...
@@ -199,8 +199,8 @@ int conf_add_hook(conf_t * conf, int sections,
*
* \param conf Configuration context.
*
* \retval
0 on success (EOK)
.
* \retval
<0 on error (EPARSEFAIL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EPARSEFAIL on parser error
.
*/
int
conf_parse
(
conf_t
*
conf
);
...
...
@@ -212,8 +212,8 @@ int conf_parse(conf_t *conf);
* \param conf Configuration context.
* \param src Source string.
*
* \retval
0 on success (EOK)
.
* \retval
<0 on error (EPARSEFAIL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EPARSEFAIL on parser error
.
*/
int
conf_parse_str
(
conf_t
*
conf
,
const
char
*
src
);
...
...
@@ -254,8 +254,9 @@ char* conf_find_default();
*
* \param path Path to configuration file.
*
* \retval 0 on success (EOK).
* \retval <0 on error (EINVAL, ENOENT).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on null path.
* \retval KNOT_ENOENT if the path doesn't exist.
*/
int
conf_open
(
const
char
*
path
);
...
...
src/knot/conf/logconf.h
View file @
debf7d33
...
...
@@ -19,8 +19,9 @@ struct conf_t;
*
* \see syslog.h
*
* \retval 0 On success (EOK).
* \retval <0 If an error occured (EINVAL, ENOMEM).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOMEM out of memory error.
*/
int
log_conf_hook
(
const
struct
conf_t
*
conf
,
void
*
data
);
...
...
src/knot/ctl/process.h
View file @
debf7d33
...
...
@@ -27,8 +27,10 @@ char* pid_filename();
*
* \param fn Filename containing PID.
*
* \retval PID on success.
* \retval negative integer on error (EINVAL, ENOENT, ERANGE).
* \retval PID on success (positive integer).
* \retval KNOT_EINVAL on null path.
* \retval KNOT_ENOENT if the filename content cannot be read.
* \retval KNOT_ERANGE if the stored PID is out of range.
*/
pid_t
pid_read
(
const
char
*
fn
);
...
...
@@ -37,8 +39,10 @@ pid_t pid_read(const char* fn);
*
* \param fn Filename containing PID.
*
* \retval 0 on success (EOK).
* \retval negative integer on error (ENOENT, EINVAL, ERROR).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on null path.
* \retval KNOT_ENOENT filename cannot be opened for writing.
* \retval KNOT_ERROR unspecified error.
*/
int
pid_write
(
const
char
*
fn
);
...
...
@@ -49,8 +53,8 @@ int pid_write(const char* fn);
*
* \warning Filename content won't be checked.
*
* \retval
0 on success (EOK)
.
* \retval
negative integer on error (EINVAL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL failed to remove filename
.
*/
int
pid_remove
(
const
char
*
fn
);
...
...
@@ -59,8 +63,8 @@ int pid_remove(const char* fn);
*
* \param pid Process ID.
*
* \retval
True
if running.
* \retval
False if not running or on errors
.
* \retval
1
if running.
* \retval
0 if not running (or error)
.
*/
int
pid_running
(
pid_t
pid
);
...
...
src/knot/main.c
View file @
debf7d33
...
...
@@ -4,6 +4,7 @@
#include <unistd.h>
#include "knot/common.h"
#include "knot/other/error.h"
#include "knot/server/server.h"
#include "zcompile/zcompile.h"
#include "knot/ctl/process.h"
...
...
@@ -41,7 +42,7 @@ void interrupt_handle(int s)
void
help
(
int
argc
,
char
**
argv
)
{
printf
(
"Usage: %s [parameters]
[<filename1> <filename2> ...]
\n
"
,
printf
(
"Usage: %s [parameters]
\n
"
,
argv
[
0
]);
printf
(
"Parameters:
\n
"
" -c [file] Select configuration file.
\n
"
...
...
@@ -90,10 +91,6 @@ int main(int argc, char **argv)
// Initialize log
log_init
();
// Check if there's at least one remaining non-option
int
zfs_count
=
argc
-
optind
;
const
char
**
zfs
=
(
const
char
**
)
argv
+
optind
;
// Now check if we want to daemonize
if
(
daemonize
)
{
if
(
daemon
(
1
,
0
)
!=
0
)
{
...
...
@@ -123,19 +120,12 @@ int main(int argc, char **argv)
// Open configuration
log_server_info
(
"Parsing configuration...
\n
"
);
if
(
conf_open
(
config_fn
)
!=
0
)
{
if
(
conf_open
(
config_fn
)
!=
KNOT_EOK
)
{
log_server_error
(
"Failed to parse configuration '%s'.
\n
"
,
config_fn
);
if
(
zfs_count
<
1
)
{
log_server_fatal
(
"No zone files specified, "
"shutting down.
\n\n
"
);
help
(
argc
,
argv
);
log_close
();
free
(
default_fn
);
return
1
;
}
log_server_warning
(
"No zone served.
\n
"
);
}
else
{
log_server_info
(
"Configured %d interfaces and %d zones.
\n
"
,
conf
()
->
ifaces_count
,
conf
()
->
zones_count
);
...
...
@@ -155,7 +145,7 @@ int main(int argc, char **argv)
// Run server
int
res
=
0
;
log_server_info
(
"Starting server...
\n
"
);
if
((
res
=
server_start
(
server
,
zfs
,
zfs_count
))
==
0
)
{
if
((
res
=
server_start
(
server
))
==
KNOT_EOK
)
{
// Save PID
if
(
daemonize
)
{
...
...
@@ -169,11 +159,11 @@ int main(int argc, char **argv)
// Change directory if daemonized
if
(
daemonize
)
{
log_server_info
(
"Server started as a daemon, "
"PID
=
\"
%ld
\"
.
\n
"
,
(
long
)
getpid
());
"PID
= %ld
\n
"
,
(
long
)
getpid
());
res
=
chdir
(
"/"
);
}
else
{
log_server_info
(
"Server started in foreground, "
"PID
=
\"
%ld
\"
.
\n
"
,
(
long
)
getpid
());
"PID
= %ld
\n
"
,
(
long
)
getpid
());
}
log_server_info
(
"
\n
"
);
...
...
@@ -231,7 +221,7 @@ int main(int argc, char **argv)
}
}
if
((
res
=
server_wait
(
server
))
!=
0
)
{
if
((
res
=
server_wait
(
server
))
!=
KNOT_EOK
)
{
log_server_error
(
"An error occured while "
"waiting for server to finish.
\n
"
);
}
else
{
...
...
src/knot/other/error.c
View file @
debf7d33
...
...
@@ -19,11 +19,10 @@ const error_table_t knot_error_msgs[] = {
/* Custom errors. */
{
KNOT_ERROR
,
"Generic error."
},
{
KNOT_EADDRINVAL
,
"Invalid address."
},
{
KNOT_EZONEINVAL
,
"Invalid zone file."
},
{
KNOT_ENOTRUNNING
,
"Resource is not running."
},
{
KNOT_EPARSEFAIL
,
"Parser failed."
},
{
KNOT_ENOIPV6
,
"IPv6 support disabled."
},
{
KNOT_EMALF
,
"Malformed
packet
."
},
{
KNOT_EMALF
,
"Malformed
data
."
},
{
KNOT_ERROR
,
0
}
};
src/knot/other/error.h
View file @
debf7d33
...
...
@@ -41,12 +41,11 @@ enum knot_error_t {
/* Custom error codes. */
KNOT_ERROR
=
-
16384
,
/*!< \brief Generic error. */
KNOT_EADDRINVAL
,
/*!< \brief Invalid address. */
KNOT_EZONEINVAL
,
/*!< \brief Invalid zone file. */
KNOT_ENOTRUNNING
,
/*!< \brief Resource is not running. */
KNOT_EPARSEFAIL
,
/*!< \brief Parser fail. */
KNOT_ENOIPV6
,
/*!< \brief No IPv6 support. */
KNOT_EMALF
,
/*!<
Malformed packet
. */
KNOT_EMALF
,
/*!<
\brief Malformed data
. */
KNOT_ERROR_COUNT
=
20
};
...
...
src/knot/other/log.c
View file @
debf7d33
...
...
@@ -82,11 +82,10 @@ int log_init()
return
ret
;
}
int
log_close
()
void
log_close
()
{
log_truncate
();
closelog
();
return
0
;
}
void
log_truncate
()
...
...
src/knot/other/log.h
View file @
debf7d33
...
...
@@ -58,8 +58,8 @@ typedef enum {
*
* \param logfiles Number of extra logfiles.
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL, ENOMEM
).
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL invalid number of logfiles (negative
).
*/
int
log_setup
(
int
logfiles
);
...
...
@@ -68,18 +68,15 @@ int log_setup(int logfiles);
*
* \see syslog.h
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL, ENOMEM)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_ENOMEM out of memory error
.
*/
int
log_init
();
/*!
* \brief Close and deinitialize log.
*
* \retval 0 On success (EOK).
* \retval <0 If an error occured ().
*/
int
log_close
();
void
log_close
();
/*!
* \brief Truncate current log setup.
...
...
@@ -100,7 +97,8 @@ int log_isopen();
* \param filename File path.
*
* \retval associated facility index on success.
* \retval <0 on error (EINVAL, ERROR).
* \retval KNOT_EINVAL filename cannot be opened for writing.
* \retval KNOT_ERROR unspecified error.
*/
int
log_open_file
(
const
char
*
filename
);
...
...
@@ -122,8 +120,8 @@ uint8_t log_levels(int facility, logsrc_t src);
* \param src Logging source (LOG_SERVER...LOG_ANY).
* \param levels Bitmask of specified log levels.
*
* \retval
0 On success (EOK)
.
* \retval
<0 On error (EINVAL
).
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL invalid parameters (facility out of range
).
*/
int
log_levels_set
(
int
facility
,
logsrc_t
src
,
uint8_t
levels
);
...
...
@@ -137,8 +135,8 @@ int log_levels_set(int facility, logsrc_t src, uint8_t levels);
* \param src Logging source (LOG_SERVER...LOG_ANY).
* \param levels Bitmask of specified log levels.
*
* \retval
0 On success (EOK)
.
* \retval
<0 On error (EINVAL
).
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL invalid parameters (facility out of range
).
*/
int
log_levels_add
(
int
facility
,
logsrc_t
src
,
uint8_t
levels
);
...
...
@@ -151,9 +149,10 @@ int log_levels_add(int facility, logsrc_t src, uint8_t levels);
* \param level Message error level.
* \param msg Content of the logged message.
*
* \retval <0 On error (EINVAL, ERROR).
* \retval 0 When the message is ignored.
* \retval >0 On success.
* \retval Number of logged bytes on success.
* \retval 0 When the message is ignored.
* \retval KNOT_EINVAL invalid parameters.
* \retval KNOT_ERROR unspecified error.
*/
int
log_msg
(
logsrc_t
src
,
int
level
,
const
char
*
msg
,
...)
__attribute__
((
format
(
printf
,
3
,
4
)));
...
...
src/knot/server/dthreads.c
View file @
debf7d33
...
...
@@ -974,7 +974,7 @@ int dt_unit_lock(dt_unit_t *unit)
/* Map errors. */
if
(
ret
<
0
)
{
return
knot_map_errno
(
E
BUSY
,
E
INVAL
,
EAGAIN
);
return
knot_map_errno
(
EINVAL
,
EAGAIN
);
}
return
KNOT_EOK
;
...
...
@@ -984,14 +984,14 @@ int dt_unit_unlock(dt_unit_t *unit)
{
// Check input
if
(
unit
==
0
)
{
return
-
1
;
return
KNOT_EINVAL
;
}
int
ret
=
pthread_mutex_unlock
(
&
unit
->
_mx
);
/* Map errors. */
if
(
ret
<
0
)
{
return
knot_map_errno
(
E
BUSY
,
E
INVAL
,
EAGAIN
);
return
knot_map_errno
(
EINVAL
,
EAGAIN
);
}
return
KNOT_EOK
;
...
...
src/knot/server/dthreads.h
View file @
debf7d33
...
...
@@ -134,15 +134,16 @@ void dt_delete(dt_unit_t **unit);
*
* \warning Be careful when shrinking unit, joined and idle threads are
* reclaimed first, but it may kill your active threads
* as a lastresort.
* as a last
resort.
* Threads will stop at their nearest cancellation point,
* so this is potentially an expensive and blocking operation.
*
* \param unit Unit to be resized.
* \param size New unit size.
*
* \retval 0 On success.
* \retval <0 If an error occured (EINVAL, ENOMEM).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOMEM out of memory error.
*/
int
dt_resize
(
dt_unit_t
*
unit
,
int
size
);
...
...
@@ -151,8 +152,8 @@ int dt_resize(dt_unit_t *unit, int size);
*
* \param unit Unit to be started.
*
* \retval
0 O
n success.
* \retval
<0 If an error occured (EINVAL
).
* \retval
KNOT_EOK o
n success.
* \retval
KNOT_EINVAL on invalid parameters (unit is null
).
*/
int
dt_start
(
dt_unit_t
*
unit
);
...
...
@@ -161,8 +162,8 @@ int dt_start(dt_unit_t *unit);
*
* \param thread Target thread instance.
*
* \retval
0 O
n success.
* \retval
<0 If an error occured (EINVAL)
.
* \retval
KNOT_EOK o
n success.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_start_id
(
dthread_t
*
thread
);
...
...
@@ -176,8 +177,9 @@ int dt_start_id(dthread_t *thread);
* \param thread Target thread instance.
* \param signum Signal code.
*
* \retval 0 On success (EOK).
* \retval <0 If an error occured (EINVAL, ERROR).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ERROR unspecified error.
*/
int
dt_signalize
(
dthread_t
*
thread
,
int
signum
);
...
...
@@ -186,8 +188,8 @@ int dt_signalize(dthread_t *thread, int signum);
*
* \param unit Unit to be joined.
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_join
(
dt_unit_t
*
unit
);
...
...
@@ -198,8 +200,8 @@ int dt_join(dt_unit_t *unit);
*
* \param thread Target thread instance.
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_stop_id
(
dthread_t
*
thread
);
...
...
@@ -210,8 +212,8 @@ int dt_stop_id(dthread_t *thread);
*
* \param unit Unit to be stopped.
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_stop
(
dt_unit_t
*
unit
);
...
...
@@ -221,8 +223,8 @@ int dt_stop(dt_unit_t *unit);
* \param thread Target thread instance.
* \param prio Requested priority (positive integer, default is 0).
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_setprio
(
dthread_t
*
thread
,
int
prio
);
...
...
@@ -233,8 +235,9 @@ int dt_setprio(dthread_t *thread, int prio);
* \param runnable Runnable function for target thread.
* \param data Data passed to target thread.
*
* \retval 0 On success (EOK).
* \retval <0 If an error occured (EINVAL, ENOTSUP).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOTSUP operation not supported.
*/
int
dt_repurpose
(
dthread_t
*
thread
,
runnable_t
runnable
,
void
*
data
);
...
...
@@ -249,8 +252,9 @@ int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data);
*
* \param thread Target thread instance.
*
* \retval 0 On success (EOK).
* \retval <0 If an error occured (EINVAL, ENOTSUP).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOTSUP operation not supported.
*/
int
dt_activate
(
dthread_t
*
thread
);
...
...
@@ -265,8 +269,8 @@ int dt_activate(dthread_t *thread);
*
* \param thread Target thread instance.
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL, ENOTSUP)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_cancel
(
dthread_t
*
thread
);
...
...
@@ -275,8 +279,8 @@ int dt_cancel(dthread_t *thread);
*
* \param unit Target unit instance.
*
* \retval
0 On success (EOK)
.
* \retval
<0 If an error occured (EINVAL)
.
* \retval
KNOT_EOK on success
.
* \retval
KNOT_EINVAL on invalid parameters
.
*/
int
dt_compact
(
dt_unit_t
*
unit
);
...
...
@@ -297,8 +301,8 @@ int dt_optimal_size();
*
* \param thread Target thread instance.
*
* \retval
Logical true
if cancelled.
* \retval
Logical false
if not cancelled.
* \retval
1
if cancelled.
* \retval
0
if not cancelled.
*/
int
dt_is_cancelled
(
dthread_t
*
thread
);
...
...
@@ -308,8 +312,10 @@ int dt_is_cancelled(dthread_t *thread);
*
* \param unit Target unit instance.
*
* \retval 0 On success.
* \retval <0 If an error occured.
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_EAGAIN lack of resources to lock unit, try again.
* \retval KNOT_ERROR unspecified error.
*/
int
dt_unit_lock
(
dt_unit_t
*
unit
);
...
...
@@ -320,8 +326,10 @@ int dt_unit_lock(dt_unit_t *unit);
*
* \param unit Target unit instance.
*
* \retval 0 On success (EOK).
* \retval <0 If an error occured (ERROR, ENOMEM, EINVAL, EBUSY, EAGAIN).
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_EAGAIN lack of resources to unlock unit, try again.
* \retval KNOT_ERROR unspecified error.
*/
int
dt_unit_unlock
(
dt_unit_t
*
unit
);
...
...
src/knot/server/name-server.h
View file @
debf7d33
...
...
@@ -65,8 +65,8 @@ ns_nameserver_t *ns_create();
* \param rsize Input: maximum acceptable size of the response. Output: real
* size of the response.
*
* \retval
0
if a valid response was created.
* \retval
-1
if an error occured and the response is not valid.
* \retval
KNOT_EOK
if a valid response was created.
* \retval
KNOT_EMALF
if an error occured and the response is not valid.
*
* \todo Truncation of the packet.
*/
...
...
@@ -90,6 +90,10 @@ void ns_destroy(ns_nameserver_t **nameserver);
*
* \param conf Current configuration.
* \param data Instance of the nameserver structure to update.
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL
* \retval KNOT_ERROR
*/
int
ns_conf_hook
(
const
struct
conf_t
*
conf
,
void
*
data
);
...
...
src/knot/server/server.c
View file @
debf7d33
...
...
@@ -429,97 +429,13 @@ int server_remove_handler(server_t *server, iohandler_t *h)
return
KNOT_EOK
;
}
int
server_start
(
server_t
*
server
,
const
char
**
filenames
,
uint
zones
)
int
server_start
(
server_t
*
server
)
{
// Check server
if
(
server
==
0
)
{
return
KNOT_EINVAL
;
}
#if 0
/* Percentage. */
int zones_total = zones + conf()->zones_count;
int pct = 0, pct_step = 10;
int pct_threshold = pct + pct_step;
double pct_incr = 100.0 / zones_total;
/* Lock configuration. */
conf_read_lock();
log_server_info("Loading zone files...\n");
//stat
stat_static_gath_start();
//!stat
/* Load zones from config. */
node *n = 0; int zones_loaded = 0;
WALK_LIST (n, conf()->zones) {
conf_zone_t *z = (conf_zone_t*)n;
/* Attempt to read db header. */
zloader_t *zl = dnslib_zload_open(z->db);
if (zl == NULL) {
log_server_error("Zone source file for '%s' "
"doesn't exists.\n",
z->name);
continue;
}
assert(zl != NULL);
/* Check zone source file against configured source. */
int src_changed = strcmp(z->file, zl->source) != 0;
if (src_changed) {
log_server_warning("Zone source file for '%s' "
"has changed, it is recommended to "
"recompile it.\n",
z->name);
}
dnslib_zload_close(zl);
// Load zone
if (zones_load_zone(server->zone_db, z->name, z->db) == 0) {
++zones_loaded;
}
pct += pct_incr;
while (pct >= pct_threshold) {
log_server_info("..%d%%", pct_threshold);
pct_threshold += pct_step;
}
}
/* Unlock configuration. */
conf_read_unlock();
// Load given zones
for (uint i = 0; i < zones; ++i) {
if (zones_load_zone(server->zone_db, "??", filenames[i])
== 0) {
++zones_loaded;
}
pct += pct_incr;
while (pct >= pct_threshold) {
log_server_info("..%d%%", pct_threshold);
pct_threshold += pct_step;
}
}
log_server_info("\n");
/* Check the number of loaded zones. */
if (zones_loaded == 0) {
log_server_error("No valid zone found.\n");
} else {
log_server_info("Successfully loaded %d/%d zones.\n",
zones_loaded, zones_total);
}
#endif
debug_server
(
"Starting handlers...
\n
"
);
/* Lock configuration. */
...
...
src/knot/server/server.h
View file @
debf7d33
...
...
@@ -88,9 +88,6 @@ typedef struct server_t {
/*! \brief Reference to the name server structure. */
ns_nameserver_t
*
nameserver
;
/*! \brief Reference to the zone database structure. */
dnslib_zonedb_t
*
zone_db
;
/*! \brief I/O handlers list. */
list
handlers
;
...
...
@@ -105,7 +102,7 @@ typedef struct server_t {
* Creates all other main structures.
*
* \retval New instance if successful.
* \retval
0
If an error occured.
* \retval
NULL
If an error occured.
*/
server_t
*
server_create
();
...
...
@@ -120,7 +117,7 @@ server_t *server_create();
<