Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
595762d0
Commit
595762d0
authored
Aug 29, 2001
by
sasha@mysql.sashanet.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed coredump, and changed mngd->manager
parent
1c4be70c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
66 deletions
+72
-66
.bzrignore
.bzrignore
+1
-0
sql/sql_acl.cc
sql/sql_acl.cc
+6
-1
tools/Makefile.am
tools/Makefile.am
+3
-3
tools/mysqlmanager.c
tools/mysqlmanager.c
+62
-62
No files found.
.bzrignore
View file @
595762d0
...
@@ -399,3 +399,4 @@ tools/mysys_priv.h
...
@@ -399,3 +399,4 @@ tools/mysys_priv.h
vio/test-sslclient
vio/test-sslclient
vio/test-sslserver
vio/test-sslserver
vio/viotest-ssl
vio/viotest-ssl
tools/mysqlmanager
sql/sql_acl.cc
View file @
595762d0
...
@@ -61,7 +61,9 @@ public:
...
@@ -61,7 +61,9 @@ public:
uint
hostname_length
;
uint
hostname_length
;
char
*
user
,
*
password
;
char
*
user
,
*
password
;
ulong
salt
[
2
];
ulong
salt
[
2
];
#ifdef HAVE_OPENSSL
char
*
ssl_type
,
*
ssl_cipher
,
*
ssl_issuer
,
*
ssl_subject
;
char
*
ssl_type
,
*
ssl_cipher
,
*
ssl_issuer
,
*
ssl_subject
;
#endif
};
};
class
ACL_DB
:
public
ACL_ACCESS
class
ACL_DB
:
public
ACL_ACCESS
...
@@ -200,10 +202,12 @@ int acl_init(bool dont_read_acl_tables)
...
@@ -200,10 +202,12 @@ int acl_init(bool dont_read_acl_tables)
update_hostname
(
&
user
.
host
,
get_field
(
&
mem
,
table
,
0
));
update_hostname
(
&
user
.
host
,
get_field
(
&
mem
,
table
,
0
));
user
.
user
=
get_field
(
&
mem
,
table
,
1
);
user
.
user
=
get_field
(
&
mem
,
table
,
1
);
user
.
password
=
get_field
(
&
mem
,
table
,
2
);
user
.
password
=
get_field
(
&
mem
,
table
,
2
);
#ifdef HAVE_OPENSSL
user
.
ssl_type
=
get_field
(
&
mem
,
table
,
17
);
user
.
ssl_type
=
get_field
(
&
mem
,
table
,
17
);
user
.
ssl_cipher
=
get_field
(
&
mem
,
table
,
18
);
user
.
ssl_cipher
=
get_field
(
&
mem
,
table
,
18
);
user
.
ssl_issuer
=
get_field
(
&
mem
,
table
,
19
);
user
.
ssl_issuer
=
get_field
(
&
mem
,
table
,
19
);
user
.
ssl_subject
=
get_field
(
&
mem
,
table
,
20
);
user
.
ssl_subject
=
get_field
(
&
mem
,
table
,
20
);
#endif
if
(
user
.
password
&&
(
length
=
(
uint
)
strlen
(
user
.
password
))
==
8
&&
if
(
user
.
password
&&
(
length
=
(
uint
)
strlen
(
user
.
password
))
==
8
&&
protocol_version
==
PROTOCOL_VERSION
)
protocol_version
==
PROTOCOL_VERSION
)
{
{
...
@@ -2416,6 +2420,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
...
@@ -2416,6 +2420,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
global
.
append
(
passd_buff
);
global
.
append
(
passd_buff
);
global
.
append
(
'\''
);
global
.
append
(
'\''
);
}
}
#ifdef HAVE_OPENSSL
/* SSL grant stuff */
/* SSL grant stuff */
DBUG_PRINT
(
"info"
,(
"acl_user->ssl_type=%s"
,
acl_user
->
ssl_type
));
DBUG_PRINT
(
"info"
,(
"acl_user->ssl_type=%s"
,
acl_user
->
ssl_type
));
DBUG_PRINT
(
"info"
,(
"acl_user->ssl_cipher=%s"
,
acl_user
->
ssl_cipher
));
DBUG_PRINT
(
"info"
,(
"acl_user->ssl_cipher=%s"
,
acl_user
->
ssl_cipher
));
...
@@ -2439,7 +2444,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
...
@@ -2439,7 +2444,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
}
}
}
}
}
#endif
if
(
want_access
&
GRANT_ACL
)
if
(
want_access
&
GRANT_ACL
)
global
.
append
(
" WITH GRANT OPTION"
,
18
);
global
.
append
(
" WITH GRANT OPTION"
,
18
);
thd
->
packet
.
length
(
0
);
thd
->
packet
.
length
(
0
);
...
...
tools/Makefile.am
View file @
595762d0
...
@@ -3,9 +3,9 @@ INCLUDES = -I$(srcdir)/../include $(openssl_includes) \
...
@@ -3,9 +3,9 @@ INCLUDES = -I$(srcdir)/../include $(openssl_includes) \
-I
..
-I
..
LIBS
=
@TOOLS_LIBS@
LIBS
=
@TOOLS_LIBS@
LDADD
=
@CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la
LDADD
=
@CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la
bin_PROGRAMS
=
mysqlm
ngd
bin_PROGRAMS
=
mysqlm
anager
mysqlm
ngd_SOURCES
=
mysqlmngd.c my_vsnprintf
.c
mysqlm
anager_SOURCES
=
mysqlmanager
.c
#mysqltest
_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqlmanager
_DEPENDENCIES
=
$(LIBRARIES)
$(pkglib_LTLIBRARIES)
DEFS
=
-DUNDEF_THREADS_HACK
DEFS
=
-DUNDEF_THREADS_HACK
# Don't update the files from bitkeeper
# Don't update the files from bitkeeper
...
...
tools/mysqlm
ngd
.c
→
tools/mysqlm
anager
.c
View file @
595762d0
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
#endif
#endif
#ifndef MNGD_LOG_FILE
#ifndef MNGD_LOG_FILE
#define MNGD_LOG_FILE "/var/log/mysqlm
ngd
.log"
#define MNGD_LOG_FILE "/var/log/mysqlm
anager
.log"
#endif
#endif
#ifndef MNGD_BACK_LOG
#ifndef MNGD_BACK_LOG
...
@@ -68,22 +68,22 @@
...
@@ -68,22 +68,22 @@
#define MAX_USER_NAME 16
#define MAX_USER_NAME 16
#endif
#endif
/* Variable naming convention - if starts with m
ngd
_, either is set
/* Variable naming convention - if starts with m
anager
_, either is set
directly by the user, or used closely in ocnjunction with a variable
directly by the user, or used closely in ocnjunction with a variable
set by the user
set by the user
*/
*/
uint
m
ngd
_port
=
MNGD_PORT
;
uint
m
anager
_port
=
MNGD_PORT
;
FILE
*
errfp
;
FILE
*
errfp
;
const
char
*
m
ngd
_log_file
=
MNGD_LOG_FILE
;
const
char
*
m
anager
_log_file
=
MNGD_LOG_FILE
;
pthread_mutex_t
lock_log
,
lock_shutdown
;
pthread_mutex_t
lock_log
,
lock_shutdown
;
int
m
ngd
_sock
=
-
1
;
int
m
anager
_sock
=
-
1
;
struct
sockaddr_in
m
ngd
_addr
;
struct
sockaddr_in
m
anager
_addr
;
ulong
m
ngd
_bind_addr
=
INADDR_ANY
;
ulong
m
anager
_bind_addr
=
INADDR_ANY
;
int
m
ngd
_back_log
=
MNGD_BACK_LOG
;
int
m
anager
_back_log
=
MNGD_BACK_LOG
;
int
in_shutdown
=
0
,
shutdown_requested
=
0
;
int
in_shutdown
=
0
,
shutdown_requested
=
0
;
const
char
*
m
ngd
_greeting
=
MNGD_GREETING
;
const
char
*
m
anager
_greeting
=
MNGD_GREETING
;
uint
m
ngd
_max_cmd_len
=
MNGD_MAX_CMD_LEN
;
uint
m
anager
_max_cmd_len
=
MNGD_MAX_CMD_LEN
;
/* messages */
/* messages */
...
@@ -103,7 +103,7 @@ uint mngd_max_cmd_len = MNGD_MAX_CMD_LEN;
...
@@ -103,7 +103,7 @@ uint mngd_max_cmd_len = MNGD_MAX_CMD_LEN;
#define PRIV_SHUTDOWN 1
#define PRIV_SHUTDOWN 1
struct
m
ngd
_thd
struct
m
anager
_thd
{
{
Vio
*
vio
;
Vio
*
vio
;
char
user
[
MAX_USER_NAME
];
char
user
[
MAX_USER_NAME
];
...
@@ -112,25 +112,25 @@ struct mngd_thd
...
@@ -112,25 +112,25 @@ struct mngd_thd
int
fatal
,
finished
;
int
fatal
,
finished
;
};
};
struct
m
ngd_thd
*
mngd
_thd_new
(
Vio
*
vio
);
struct
m
anager_thd
*
manager
_thd_new
(
Vio
*
vio
);
void
m
ngd_thd_free
(
struct
mngd
_thd
*
thd
);
void
m
anager_thd_free
(
struct
manager
_thd
*
thd
);
typedef
int
(
*
m
ngd_cmd_handler
)(
struct
mngd
_thd
*
,
char
*
,
char
*
);
typedef
int
(
*
m
anager_cmd_handler
)(
struct
manager
_thd
*
,
char
*
,
char
*
);
struct
m
ngd
_cmd
struct
m
anager
_cmd
{
{
const
char
*
name
;
const
char
*
name
;
const
char
*
help
;
const
char
*
help
;
m
ngd
_cmd_handler
handler_func
;
m
anager
_cmd_handler
handler_func
;
int
len
;
int
len
;
};
};
#define HANDLE_DECL(com) static int handle_ ## com (struct m
ngd
_thd* thd,\
#define HANDLE_DECL(com) static int handle_ ## com (struct m
anager
_thd* thd,\
char* args_start,char* args_end)
char* args_start,char* args_end)
#define HANDLE_NOARG_DECL(com) static int handle_ ## com \
#define HANDLE_NOARG_DECL(com) static int handle_ ## com \
(struct m
ngd
_thd* thd, char* __attribute__((unused)) args_start,\
(struct m
anager
_thd* thd, char* __attribute__((unused)) args_start,\
char* __attribute__((unused)) args_end)
char* __attribute__((unused)) args_end)
...
@@ -139,7 +139,7 @@ HANDLE_NOARG_DECL(quit);
...
@@ -139,7 +139,7 @@ HANDLE_NOARG_DECL(quit);
HANDLE_NOARG_DECL
(
help
);
HANDLE_NOARG_DECL
(
help
);
HANDLE_NOARG_DECL
(
shutdown
);
HANDLE_NOARG_DECL
(
shutdown
);
struct
m
ngd
_cmd
commands
[]
=
struct
m
anager
_cmd
commands
[]
=
{
{
{
"ping"
,
"Check if this server is alive"
,
handle_ping
,
4
},
{
"ping"
,
"Check if this server is alive"
,
handle_ping
,
4
},
{
"quit"
,
"Finish session"
,
handle_quit
,
4
},
{
"quit"
,
"Finish session"
,
handle_quit
,
4
},
...
@@ -165,22 +165,22 @@ struct option long_options[] =
...
@@ -165,22 +165,22 @@ struct option long_options[] =
static
void
die
(
const
char
*
fmt
,...);
static
void
die
(
const
char
*
fmt
,...);
static
void
print_time
(
FILE
*
fp
);
static
void
print_time
(
FILE
*
fp
);
static
void
clean_up
();
static
void
clean_up
();
static
struct
m
ngd
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
);
static
struct
m
anager
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
);
static
void
client_msg
(
Vio
*
vio
,
int
err_code
,
const
char
*
fmt
,...);
static
void
client_msg
(
Vio
*
vio
,
int
err_code
,
const
char
*
fmt
,...);
static
void
client_msg_pre
(
Vio
*
vio
,
int
err_code
,
const
char
*
fmt
,...);
static
void
client_msg_pre
(
Vio
*
vio
,
int
err_code
,
const
char
*
fmt
,...);
static
void
client_msg_raw
(
Vio
*
vio
,
int
err_code
,
int
pre
,
const
char
*
fmt
,
static
void
client_msg_raw
(
Vio
*
vio
,
int
err_code
,
int
pre
,
const
char
*
fmt
,
va_list
args
);
va_list
args
);
static
int
authenticate
(
struct
m
ngd
_thd
*
thd
);
static
int
authenticate
(
struct
m
anager
_thd
*
thd
);
static
char
*
read_line
(
struct
m
ngd
_thd
*
thd
);
/* returns pointer to end of
static
char
*
read_line
(
struct
m
anager
_thd
*
thd
);
/* returns pointer to end of
line
line
*/
*/
static
pthread_handler_decl
(
process_connection
,
arg
);
static
pthread_handler_decl
(
process_connection
,
arg
);
static
int
exec_line
(
struct
m
ngd
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
);
static
int
exec_line
(
struct
m
anager
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
);
static
int
exec_line
(
struct
m
ngd
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
)
static
int
exec_line
(
struct
m
anager
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
)
{
{
char
*
p
=
buf
;
char
*
p
=
buf
;
struct
m
ngd
_cmd
*
cmd
;
struct
m
anager
_cmd
*
cmd
;
for
(;
p
<
buf_end
&&
!
isspace
(
*
p
);
p
++
)
for
(;
p
<
buf_end
&&
!
isspace
(
*
p
);
p
++
)
*
p
=
tolower
(
*
p
);
*
p
=
tolower
(
*
p
);
if
(
!
(
cmd
=
lookup_cmd
(
buf
,(
int
)(
p
-
buf
))))
if
(
!
(
cmd
=
lookup_cmd
(
buf
,(
int
)(
p
-
buf
))))
...
@@ -193,9 +193,9 @@ static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end)
...
@@ -193,9 +193,9 @@ static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end)
return
cmd
->
handler_func
(
thd
,
p
,
buf_end
);
return
cmd
->
handler_func
(
thd
,
p
,
buf_end
);
}
}
static
struct
m
ngd
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
)
static
struct
m
anager
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
)
{
{
struct
m
ngd
_cmd
*
cmd
=
commands
;
struct
m
anager
_cmd
*
cmd
=
commands
;
for
(;
cmd
->
name
;
cmd
++
)
for
(;
cmd
->
name
;
cmd
++
)
{
{
if
(
cmd
->
len
==
len
&&
!
memcmp
(
cmd
->
name
,
s
,
len
))
if
(
cmd
->
len
==
len
&&
!
memcmp
(
cmd
->
name
,
s
,
len
))
...
@@ -219,7 +219,7 @@ HANDLE_NOARG_DECL(quit)
...
@@ -219,7 +219,7 @@ HANDLE_NOARG_DECL(quit)
HANDLE_NOARG_DECL
(
help
)
HANDLE_NOARG_DECL
(
help
)
{
{
struct
m
ngd
_cmd
*
cmd
=
commands
;
struct
m
anager
_cmd
*
cmd
=
commands
;
Vio
*
vio
=
thd
->
vio
;
Vio
*
vio
=
thd
->
vio
;
client_msg_pre
(
vio
,
MSG_INFO
,
"Available commands:"
);
client_msg_pre
(
vio
,
MSG_INFO
,
"Available commands:"
);
for
(;
cmd
->
name
;
cmd
++
)
for
(;
cmd
->
name
;
cmd
++
)
...
@@ -238,10 +238,10 @@ HANDLE_NOARG_DECL(shutdown)
...
@@ -238,10 +238,10 @@ HANDLE_NOARG_DECL(shutdown)
return
0
;
return
0
;
}
}
static
int
authenticate
(
struct
m
ngd
_thd
*
thd
)
static
int
authenticate
(
struct
m
anager
_thd
*
thd
)
{
{
char
*
buf_end
;
char
*
buf_end
;
client_msg
(
thd
->
vio
,
MSG_INFO
,
m
ngd
_greeting
);
client_msg
(
thd
->
vio
,
MSG_INFO
,
m
anager
_greeting
);
if
(
!
(
buf_end
=
read_line
(
thd
)))
if
(
!
(
buf_end
=
read_line
(
thd
)))
return
-
1
;
return
-
1
;
client_msg
(
thd
->
vio
,
MSG_OK
,
"OK"
);
client_msg
(
thd
->
vio
,
MSG_OK
,
"OK"
);
...
@@ -327,7 +327,7 @@ LOG_MSG_FUNC(debug,DEBUG)
...
@@ -327,7 +327,7 @@ LOG_MSG_FUNC(debug,DEBUG)
static
pthread_handler_decl
(
process_connection
,
arg
)
static
pthread_handler_decl
(
process_connection
,
arg
)
{
{
struct
m
ngd_thd
*
thd
=
(
struct
mngd
_thd
*
)
arg
;
struct
m
anager_thd
*
thd
=
(
struct
manager
_thd
*
)
arg
;
my_thread_init
();
my_thread_init
();
pthread_detach_this_thread
();
pthread_detach_this_thread
();
for
(;
!
thd
->
finished
;)
for
(;
!
thd
->
finished
;)
...
@@ -340,7 +340,7 @@ static pthread_handler_decl(process_connection,arg)
...
@@ -340,7 +340,7 @@ static pthread_handler_decl(process_connection,arg)
break
;
break
;
}
}
}
}
m
ngd
_thd_free
(
thd
);
m
anager
_thd_free
(
thd
);
pthread_exit
(
0
);
pthread_exit
(
0
);
}
}
...
@@ -377,10 +377,10 @@ static void client_msg_pre(Vio* vio, int err_code, const char* fmt, ...)
...
@@ -377,10 +377,10 @@ static void client_msg_pre(Vio* vio, int err_code, const char* fmt, ...)
client_msg_raw
(
vio
,
err_code
,
1
,
fmt
,
args
);
client_msg_raw
(
vio
,
err_code
,
1
,
fmt
,
args
);
}
}
static
char
*
read_line
(
struct
m
ngd
_thd
*
thd
)
static
char
*
read_line
(
struct
m
anager
_thd
*
thd
)
{
{
char
*
p
=
thd
->
cmd_buf
;
char
*
p
=
thd
->
cmd_buf
;
char
*
buf_end
=
thd
->
cmd_buf
+
m
ngd
_max_cmd_len
;
char
*
buf_end
=
thd
->
cmd_buf
+
m
anager
_max_cmd_len
;
int
escaped
=
0
;
int
escaped
=
0
;
for
(;
p
<
buf_end
;)
for
(;
p
<
buf_end
;)
{
{
...
@@ -422,13 +422,13 @@ static char* read_line(struct mngd_thd* thd)
...
@@ -422,13 +422,13 @@ static char* read_line(struct mngd_thd* thd)
return
0
;
return
0
;
}
}
struct
m
ngd_thd
*
mngd
_thd_new
(
Vio
*
vio
)
struct
m
anager_thd
*
manager
_thd_new
(
Vio
*
vio
)
{
{
struct
m
ngd
_thd
*
tmp
;
struct
m
anager
_thd
*
tmp
;
if
(
!
(
tmp
=
(
struct
m
ngd_thd
*
)
my_malloc
(
sizeof
(
*
tmp
)
+
mngd
_max_cmd_len
,
if
(
!
(
tmp
=
(
struct
m
anager_thd
*
)
my_malloc
(
sizeof
(
*
tmp
)
+
manager
_max_cmd_len
,
MYF
(
0
))))
MYF
(
0
))))
{
{
log_err
(
"Out of memory in m
ngd
_thd_new"
);
log_err
(
"Out of memory in m
anager
_thd_new"
);
return
0
;
return
0
;
}
}
tmp
->
vio
=
vio
;
tmp
->
vio
=
vio
;
...
@@ -439,7 +439,7 @@ struct mngd_thd* mngd_thd_new(Vio* vio)
...
@@ -439,7 +439,7 @@ struct mngd_thd* mngd_thd_new(Vio* vio)
return
tmp
;
return
tmp
;
}
}
void
m
ngd_thd_free
(
struct
mngd
_thd
*
thd
)
void
m
anager_thd_free
(
struct
manager
_thd
*
thd
)
{
{
if
(
thd
->
vio
)
if
(
thd
->
vio
)
vio_close
(
thd
->
vio
);
vio_close
(
thd
->
vio
);
...
@@ -457,8 +457,8 @@ static void clean_up()
...
@@ -457,8 +457,8 @@ static void clean_up()
in_shutdown
=
1
;
in_shutdown
=
1
;
pthread_mutex_unlock
(
&
lock_shutdown
);
pthread_mutex_unlock
(
&
lock_shutdown
);
log_info
(
"Shutdown started"
);
log_info
(
"Shutdown started"
);
if
(
m
ngd
_sock
)
if
(
m
anager
_sock
)
close
(
m
ngd
_sock
);
close
(
m
anager
_sock
);
log_info
(
"Ended"
);
log_info
(
"Ended"
);
if
(
errfp
!=
stderr
)
if
(
errfp
!=
stderr
)
fclose
(
errfp
);
fclose
(
errfp
);
...
@@ -505,21 +505,21 @@ int parse_args(int argc, char **argv)
...
@@ -505,21 +505,21 @@ int parse_args(int argc, char **argv)
DBUG_PUSH
(
optarg
?
optarg
:
"d:t:O,/tmp/mysqlmgrd.trace"
);
DBUG_PUSH
(
optarg
?
optarg
:
"d:t:O,/tmp/mysqlmgrd.trace"
);
break
;
break
;
case
'P'
:
case
'P'
:
m
ngd
_port
=
atoi
(
optarg
);
m
anager
_port
=
atoi
(
optarg
);
break
;
break
;
case
'm'
:
case
'm'
:
m
ngd
_max_cmd_len
=
atoi
(
optarg
);
m
anager
_max_cmd_len
=
atoi
(
optarg
);
break
;
break
;
case
'g'
:
case
'g'
:
m
ngd
_greeting
=
optarg
;
m
anager
_greeting
=
optarg
;
case
'b'
:
case
'b'
:
m
ngd
_bind_addr
=
inet_addr
(
optarg
);
m
anager
_bind_addr
=
inet_addr
(
optarg
);
break
;
break
;
case
'B'
:
case
'B'
:
m
ngd
_back_log
=
atoi
(
optarg
);
m
anager
_back_log
=
atoi
(
optarg
);
break
;
break
;
case
'l'
:
case
'l'
:
m
ngd
_log_file
=
optarg
;
m
anager
_log_file
=
optarg
;
break
;
break
;
case
'V'
:
case
'V'
:
print_version
();
print_version
();
...
@@ -539,16 +539,16 @@ int init_server()
...
@@ -539,16 +539,16 @@ int init_server()
{
{
int
arg
=
1
;
int
arg
=
1
;
log_info
(
"Started"
);
log_info
(
"Started"
);
if
((
m
ngd
_sock
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
))
<
0
)
if
((
m
anager
_sock
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
))
<
0
)
die
(
"Could not create socket"
);
die
(
"Could not create socket"
);
bzero
((
char
*
)
&
m
ngd_addr
,
sizeof
(
mngd
_addr
));
bzero
((
char
*
)
&
m
anager_addr
,
sizeof
(
manager
_addr
));
m
ngd
_addr
.
sin_family
=
AF_INET
;
m
anager
_addr
.
sin_family
=
AF_INET
;
m
ngd_addr
.
sin_addr
.
s_addr
=
mngd
_bind_addr
;
m
anager_addr
.
sin_addr
.
s_addr
=
manager
_bind_addr
;
m
ngd_addr
.
sin_port
=
htons
(
mngd
_port
);
m
anager_addr
.
sin_port
=
htons
(
manager
_port
);
setsockopt
(
m
ngd
_sock
,
SOL_SOCKET
,
SO_REUSEADDR
,(
char
*
)
&
arg
,
sizeof
(
arg
));
setsockopt
(
m
anager
_sock
,
SOL_SOCKET
,
SO_REUSEADDR
,(
char
*
)
&
arg
,
sizeof
(
arg
));
if
(
bind
(
m
ngd_sock
,(
struct
sockaddr
*
)
&
mngd_addr
,
sizeof
(
mngd
_addr
))
<
0
)
if
(
bind
(
m
anager_sock
,(
struct
sockaddr
*
)
&
manager_addr
,
sizeof
(
manager
_addr
))
<
0
)
die
(
"Could not bind"
);
die
(
"Could not bind"
);
if
(
listen
(
m
ngd_sock
,
mngd
_back_log
)
<
0
)
if
(
listen
(
m
anager_sock
,
manager
_back_log
)
<
0
)
die
(
"Could not listen"
);
die
(
"Could not listen"
);
return
0
;
return
0
;
...
@@ -557,14 +557,14 @@ int init_server()
...
@@ -557,14 +557,14 @@ int init_server()
int
run_server_loop
()
int
run_server_loop
()
{
{
pthread_t
th
;
pthread_t
th
;
struct
m
ngd
_thd
*
thd
;
struct
m
anager
_thd
*
thd
;
int
client_sock
,
len
;
int
client_sock
,
len
;
Vio
*
vio
;
Vio
*
vio
;
for
(;
!
shutdown_requested
;)
for
(;
!
shutdown_requested
;)
{
{
len
=
sizeof
(
struct
sockaddr_in
);
len
=
sizeof
(
struct
sockaddr_in
);
if
((
client_sock
=
accept
(
m
ngd_sock
,(
struct
sockaddr
*
)
&
mngd
_addr
,
&
len
))
<
0
)
if
((
client_sock
=
accept
(
m
anager_sock
,(
struct
sockaddr
*
)
&
manager
_addr
,
&
len
))
<
0
)
{
{
if
(
shutdown_requested
)
if
(
shutdown_requested
)
break
;
break
;
...
@@ -583,7 +583,7 @@ int run_server_loop()
...
@@ -583,7 +583,7 @@ int run_server_loop()
close
(
client_sock
);
close
(
client_sock
);
continue
;
continue
;
}
}
if
(
!
(
thd
=
m
ngd
_thd_new
(
vio
)))
if
(
!
(
thd
=
m
anager
_thd_new
(
vio
)))
{
{
log_err
(
"Could not create thread object"
);
log_err
(
"Could not create thread object"
);
vio_close
(
vio
);
vio_close
(
vio
);
...
@@ -593,7 +593,7 @@ int run_server_loop()
...
@@ -593,7 +593,7 @@ int run_server_loop()
if
(
authenticate
(
thd
))
if
(
authenticate
(
thd
))
{
{
client_msg
(
vio
,
MSG_ACCESS
,
"Access denied"
);
client_msg
(
vio
,
MSG_ACCESS
,
"Access denied"
);
m
ngd
_thd_free
(
thd
);
m
anager
_thd_free
(
thd
);
continue
;
continue
;
}
}
if
(
shutdown_requested
)
if
(
shutdown_requested
)
...
@@ -602,7 +602,7 @@ int run_server_loop()
...
@@ -602,7 +602,7 @@ int run_server_loop()
{
{
client_msg
(
vio
,
MSG_INTERNAL_ERR
,
"Could not create thread, errno=%d"
,
client_msg
(
vio
,
MSG_INTERNAL_ERR
,
"Could not create thread, errno=%d"
,
errno
);
errno
);
m
ngd
_thd_free
(
thd
);
m
anager
_thd_free
(
thd
);
continue
;
continue
;
}
}
}
}
...
@@ -612,8 +612,8 @@ int run_server_loop()
...
@@ -612,8 +612,8 @@ int run_server_loop()
FILE
*
open_log_stream
()
FILE
*
open_log_stream
()
{
{
FILE
*
fp
;
FILE
*
fp
;
if
(
!
(
fp
=
fopen
(
m
ngd
_log_file
,
"a"
)))
if
(
!
(
fp
=
fopen
(
m
anager
_log_file
,
"a"
)))
die
(
"Could not open log file '%s'"
,
m
ngd
_log_file
);
die
(
"Could not open log file '%s'"
,
m
anager
_log_file
);
return
fp
;
return
fp
;
}
}
...
...
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