Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to issues #114, #118, #184. #237

Merged
merged 14 commits into from
Sep 15, 2015
Merged

Solution to issues #114, #118, #184. #237

merged 14 commits into from
Sep 15, 2015

Conversation

keshonok
Copy link
Contributor

@keshonok keshonok commented Sep 7, 2015

No description provided.

spin_unlock(&conn->splock);
if (sk) {
ss_send(sk, &msg->skb_list);
sock_put(sk);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ss_sock_put()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks bit unusual bedause double sk checking on most probable workflow, I'd rewrite it like

    sk = conn->sk;
    if (unlikely(!sk)) {
            spin_unlock(&conn->splock);                                    
            return;                                                        
    }                                                                      

    ss_sock_hold(sk);
    spin_unlock(&conn->splock);                                            

    ss_send(sk, &msg->skb_list);                                           

    ss_sock_put(sk);          

For servers TfwConnection{}.sk was set at the time a connect was attempted,
not when a connection was established. Now TfwConnection{}.sk is set only
for an established connection.
Use the usual TfwConnection{} everywhere but for a few specific cases.
- Lock is taken only for very short durations where necessary;
- Actions on connection establishing and destruction are carefully ordered;
- It should be assumed that data from schedulers is not 100% accurate;
- Don't send data on a dead connection;
Split them into more specific and fine-tuned functions that can be
called individually.
Socket hold/put operations are now tied with Tempesta's logic. Take
a hold of a socket with when connection is established, and Tempesta
is linked with Sync Sockets layer. Release the socket with connection
is closed, and Tempesta is unlinked from Sync Socket layer.
Also, comment differences in lifetime expectations.
That is completely unnecessary, as the next step is always release
of the instance of connection structure.
conn->refcnt reference counter may get down to zero in case of multiple
concurrent calls to tfw_connection_put(). However, the counter was only
initialized at the time TfwSrvConnection{} instance was created, and not
initialized when a new connection was established.

In case of server connection
…114)

Server connection instances are persistent in a sense that once created,
the instance is reused for new connections to the server. When a connection
fails it may happen that the connection still has users, and therefore can
not be reused just yet. The solution was to start a wait for an arbirtrary
time period, and then try again. The problem with the solution is that the
wait period is, well, arbitrary. Now a new connect attempt is started exactly
when there're no more users of the connection, which is when the connection
is released.
Conflicts:
	tempesta_fw/connection.c
	tempesta_fw/connection.h
	tempesta_fw/http.c
	tempesta_fw/sched/tfw_sched_hash.c
	tempesta_fw/sched/tfw_sched_rr.c
	tempesta_fw/sock.c
	tempesta_fw/sock_srv.c
Conflicts:
	tempesta_fw/sock_clnt.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants