iPXE
Data Structures | Defines | Enumerations | Functions | Variables
pool.h File Reference

Pooled connections. More...

#include <ipxe/interface.h>
#include <ipxe/list.h>
#include <ipxe/retry.h>

Go to the source code of this file.

Data Structures

struct  pooled_connection
 A pooled connection. More...

Defines

#define pool_recycle_TYPE(object_type)   typeof ( void ( object_type ) )
#define pool_reopen_TYPE(object_type)   typeof ( void ( object_type ) )

Enumerations

enum  pooled_connection_flags { POOL_RECYCLABLE = 0x0001, POOL_RECYCLED = 0x0002, POOL_ALIVE = 0x0004 }
 Pooled connection flags. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void pool_add (struct pooled_connection *pool, struct list_head *list, unsigned long expiry)
 Add connection to pool.
void pool_del (struct pooled_connection *pool)
 Remove connection from pool.
void pool_expired (struct retry_timer *timer, int over)
 Close expired pooled connection.
static __attribute__ ((always_inline)) void pool_init(struct pooled_connection *pool
 Initialise a pooled connection.
void pool_reopen (struct interface *intf)
 Reopen a defunct connection.

Variables

static void(* expired )(struct pooled_connection *pool)

Detailed Description

Pooled connections.

Definition in file pool.h.


Define Documentation

#define pool_recycle_TYPE (   object_type)    typeof ( void ( object_type ) )

Definition at line 120 of file pool.h.

#define pool_reopen_TYPE (   object_type)    typeof ( void ( object_type ) )

Definition at line 124 of file pool.h.


Enumeration Type Documentation

Pooled connection flags.

Enumerator:
POOL_RECYCLABLE 

Connection should be recycled after closing.

POOL_RECYCLED 

Connection has been recycled.

POOL_ALIVE 

Connection is known to be alive.

Definition at line 38 of file pool.h.

                             {
        /** Connection should be recycled after closing */
        POOL_RECYCLABLE = 0x0001,
        /** Connection has been recycled */
        POOL_RECYCLED = 0x0002,
        /** Connection is known to be alive */
        POOL_ALIVE = 0x0004,
};

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
void pool_add ( struct pooled_connection pool,
struct list_head list,
unsigned long  expiry 
)

Add connection to pool.

Parameters:
poolPooled connection
listList of pooled connections
expiryExpiry time

Definition at line 63 of file pool.c.

References assert, pooled_connection::list, list_add_tail, list_empty, start_timer_fixed(), and pooled_connection::timer.

Referenced by http_conn_xfer_close().

                                       {

        /* Sanity check */
        assert ( list_empty ( &pool->list ) );
        assert ( ! timer_running ( &pool->timer ) );

        /* Add to list of pooled connections */
        list_add_tail ( &pool->list, list );

        /* Start expiry timer */
        start_timer_fixed ( &pool->timer, expiry );
}
void pool_del ( struct pooled_connection pool)

Remove connection from pool.

Parameters:
poolPooled connection

Definition at line 82 of file pool.c.

References pooled_connection::flags, INIT_LIST_HEAD, pooled_connection::list, list_del, POOL_RECYCLED, stop_timer(), and pooled_connection::timer.

Referenced by http_conn_close(), and http_connect().

                                                 {

        /* Remove from list of pooled connections */
        list_del ( &pool->list );
        INIT_LIST_HEAD ( &pool->list );

        /* Stop expiry timer */
        stop_timer ( &pool->timer );

        /* Mark as a freshly recycled connection */
        pool->flags = POOL_RECYCLED;
}
void pool_expired ( struct retry_timer timer,
int over  __unused 
)

Close expired pooled connection.

Parameters:
timerExpiry timer
overFailure indicator

Definition at line 101 of file pool.c.

References assert, container_of, pooled_connection::expired, INIT_LIST_HEAD, pooled_connection::list, list_del, and list_empty.

                                                                   {
        struct pooled_connection *pool =
                container_of ( timer, struct pooled_connection, timer );

        /* Sanity check */
        assert ( ! list_empty ( &pool->list ) );

        /* Remove from connection pool */
        list_del ( &pool->list );
        INIT_LIST_HEAD ( &pool->list );

        /* Close expired connection */
        pool->expired ( pool );
}
static __attribute__ ( (always_inline)  ) [inline, static]

Initialise a pooled connection.

Parameters:
poolPooled connection
expiredClose expired pooled connection method
refcntContaining object reference counter
void pool_reopen ( struct interface intf)

Reopen a defunct connection.

Parameters:
intfData transfer interface

Definition at line 51 of file pool.c.

References intf_poke(), and pool_reopen().

Referenced by http_conn_socket_close(), and pool_reopen().

                                            {

        intf_poke ( intf, pool_reopen );
}

Variable Documentation

void( * expired)(struct pooled_connection *pool)

Definition at line 61 of file pool.h.