Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
1a452490
Commit
1a452490
authored
Mar 16, 2017
by
Ondřej Kuzník
Committed by
Ondřej Kuzník
Nov 17, 2020
Browse files
Update connection init
parent
8e0a6119
Changes
3
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/client.c
View file @
1a452490
...
...
@@ -30,10 +30,11 @@ static void
client_read_cb
(
evutil_socket_t
s
,
short
what
,
void
*
arg
)
{
Connection
*
c
=
arg
;
ldap_pvt_thread_mutex_lock
(
&
c
->
c_mutex
);
Debug
(
LDAP_DEBUG_CONNS
,
"client_read_cb: "
"connection %lu ready to read
\n
"
,
c
->
c_connid
);
evutil_closesocket
(
s
);
client_destroy
(
c
);
}
...
...
@@ -75,6 +76,7 @@ client_init(
c
->
c_write_event
=
event
;
c
->
c_private
=
listener
;
ldap_pvt_thread_mutex_unlock
(
&
c
->
c_mutex
);
return
c
;
fail:
...
...
@@ -86,6 +88,7 @@ fail:
event_del
(
c
->
c_read_event
);
event_free
(
c
->
c_read_event
);
}
c
->
c_struct_state
=
SLAP_C_UNINITIALIZED
;
connection_destroy
(
c
);
return
NULL
;
}
...
...
@@ -99,5 +102,6 @@ client_destroy( Connection *c )
event_del
(
c
->
c_write_event
);
event_free
(
c
->
c_write_event
);
c
->
c_struct_state
=
SLAP_C_UNINITIALIZED
;
connection_destroy
(
c
);
}
servers/lloadd/connection.c
View file @
1a452490
...
...
@@ -54,6 +54,14 @@ void
connection_destroy
(
Connection
*
c
)
{
assert
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"connection_destroy: "
"destroying connection %lu.
\n
"
,
c
->
c_connid
);
assert
(
c
->
c_struct_state
==
SLAP_C_UNINITIALIZED
);
evutil_closesocket
(
c
->
c_fd
);
ldap_pvt_thread_mutex_unlock
(
&
c
->
c_mutex
);
ldap_pvt_thread_mutex_destroy
(
&
c
->
c_io_mutex
);
ldap_pvt_thread_mutex_destroy
(
&
c
->
c_mutex
);
...
...
@@ -84,6 +92,7 @@ connection_init( ber_socket_t s, const char *peername, int flags )
c
=
ch_calloc
(
1
,
sizeof
(
Connection
)
);
c
->
c_fd
=
s
;
c
->
c_sb
=
ber_sockbuf_alloc
();
ber_sockbuf_ctrl
(
c
->
c_sb
,
LBER_SB_OPT_SET_FD
,
&
s
);
...
...
@@ -132,6 +141,8 @@ connection_init( ber_socket_t s, const char *peername, int flags )
}
#endif
c
->
c_next_msgid
=
1
;
ldap_pvt_thread_mutex_init
(
&
c
->
c_mutex
);
ldap_pvt_thread_mutex_init
(
&
c
->
c_io_mutex
);
...
...
@@ -141,8 +152,8 @@ connection_init( ber_socket_t s, const char *peername, int flags )
"connection connid=%lu allocated for socket fd=%d
\n
"
,
c
->
c_connid
,
s
);
ldap_pvt_thread_mutex_lock
(
&
c
->
c_mutex
);
c
->
c_struct_state
=
SLAP_C_USED
;
return
c
;
fail:
connection_destroy
(
c
);
return
NULL
;
}
servers/lloadd/slap.h
View file @
1a452490
...
...
@@ -265,7 +265,7 @@ enum sc_conn_state {
struct
Connection
{
enum
sc_struct_state
c_struct_state
;
/* structure management state */
enum
sc_conn_state
c_conn_state
;
/* connection state */
ber_socket_t
c_
s
d
;
ber_socket_t
c_
f
d
;
ldap_pvt_thread_mutex_t
c_mutex
;
/* protect the connection */
Sockbuf
*
c_sb
;
/* ber connection stuff */
...
...
@@ -275,7 +275,8 @@ struct Connection {
struct
berval
c_peer_name
;
/* peer name (trans=addr:port) */
time_t
c_starttime
;
/* when the connection was opened */
time_t
c_activitytime
;
/* when the connection was last used */
time_t
c_activitytime
;
/* when the connection was last used */
ber_int_t
c_next_msgid
;
/* msgid of the next message */
struct
event
*
c_read_event
,
*
c_write_event
;
...
...
Write
Preview
Supports
Markdown
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