mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 23:22:09 +00:00
819fc6f563
The stick table API was slightly reworked: A global spin lock on stick table was added to perform lookup and insert in a thread safe way. The handling of refcount on entries is now handled directly by stick tables functions under protection of this lock and was removed from the code of callers. The "stktable_store" function is no more externalized and users should now use "stktable_set_entry" in any case of insertion. This last one performs a lookup followed by a store if not found. So the code using "stktable_store" was re-worked. Lookup, and set_entry functions automatically increase the refcount of the returned/stored entry. The function "sticktable_touch" was renamed "sticktable_touch_local" and is now able to decrease the refcount if last arg is set to true. It is allowing to release the entry without taking the lock twice. A new function "sticktable_touch_remote" is now used to insert entries coming from remote peers at the right place in the update tree. The code of peer update was re-worked to use this new function. This function is also able to decrease the refcount if wanted. The function "stksess_kill" also handle a parameter to decrease the refcount on the entry. A read/write lock is added on each entry to protect the data content updates of the entry.
81 lines
2.2 KiB
C
81 lines
2.2 KiB
C
/*
|
|
* include/proto/session.h
|
|
* This file defines everything related to sessions.
|
|
*
|
|
* Copyright (C) 2000-2015 Willy Tarreau - w@1wt.eu
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _PROTO_SESSION_H
|
|
#define _PROTO_SESSION_H
|
|
|
|
#include <common/config.h>
|
|
#include <common/buffer.h>
|
|
#include <common/debug.h>
|
|
#include <common/memory.h>
|
|
|
|
#include <types/global.h>
|
|
#include <types/session.h>
|
|
|
|
#include <proto/stick_table.h>
|
|
|
|
extern struct pool_head *pool2_session;
|
|
struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type *origin);
|
|
void session_free(struct session *sess);
|
|
int init_session();
|
|
int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr);
|
|
|
|
/* Remove the refcount from the session to the tracked counters, and clear the
|
|
* pointer to ensure this is only performed once. The caller is responsible for
|
|
* ensuring that the pointer is valid first.
|
|
*/
|
|
static inline void session_store_counters(struct session *sess)
|
|
{
|
|
void *ptr;
|
|
int i;
|
|
struct stksess *ts;
|
|
|
|
for (i = 0; i < MAX_SESS_STKCTR; i++) {
|
|
struct stkctr *stkctr = &sess->stkctr[i];
|
|
|
|
ts = stkctr_entry(stkctr);
|
|
if (!ts)
|
|
continue;
|
|
|
|
ptr = stktable_data_ptr(stkctr->table, ts, STKTABLE_DT_CONN_CUR);
|
|
if (ptr) {
|
|
RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
|
|
|
|
stktable_data_cast(ptr, conn_cur)--;
|
|
|
|
RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
|
|
}
|
|
|
|
stkctr_set_entry(stkctr, NULL);
|
|
stksess_kill_if_expired(stkctr->table, ts, 1);
|
|
}
|
|
}
|
|
|
|
|
|
#endif /* _PROTO_SESSION_H */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*/
|