iPXE
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...

Macros

#define pool_recycle_TYPE(object_type)
#define pool_reopen_TYPE(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)
 FILE_SECBOOT (PERMITTED)
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_recycle (struct interface *intf)
 Recycle this connection after closing.
void pool_reopen (struct interface *intf)
 Reopen a defunct connection.

Variables

static void(* expired )(struct pooled_connection *pool) = expired
static void struct refcnt * refcnt
timer_init & pool

Detailed Description

Pooled connections.

Definition in file pool.h.

Macro Definition Documentation

◆ pool_recycle_TYPE

#define pool_recycle_TYPE ( object_type)
Value:
typeof ( void ( object_type ) )
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48

Definition at line 121 of file pool.h.

121#define pool_recycle_TYPE( object_type ) \
122 typeof ( void ( object_type ) )

◆ pool_reopen_TYPE

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

Definition at line 125 of file pool.h.

125#define pool_reopen_TYPE( object_type ) \
126 typeof ( void ( object_type ) )

Enumeration Type Documentation

◆ pooled_connection_flags

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 39 of file pool.h.

39 {
40 /** Connection should be recycled after closing */
41 POOL_RECYCLABLE = 0x0001,
42 /** Connection has been recycled */
43 POOL_RECYCLED = 0x0002,
44 /** Connection is known to be alive */
45 POOL_ALIVE = 0x0004,
46};
@ POOL_ALIVE
Connection is known to be alive.
Definition pool.h:45
@ POOL_RECYCLED
Connection has been recycled.
Definition pool.h:43
@ POOL_RECYCLABLE
Connection should be recycled after closing.
Definition pool.h:41

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ pool_add()

void pool_add ( struct pooled_connection * pool,
struct list_head * list,
unsigned long expiry )
extern

Add connection to pool.

Parameters
poolPooled connection
listList of pooled connections
expiryExpiry time

Definition at line 64 of file pool.c.

65 {
66
67 /* Sanity check */
68 assert ( list_empty ( &pool->list ) );
69 assert ( ! timer_running ( &pool->timer ) );
70
71 /* Add to list of pooled connections */
72 list_add_tail ( &pool->list, list );
73
74 /* Start expiry timer */
75 start_timer_fixed ( &pool->timer, expiry );
76}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition list.h:94
#define list_empty(list)
Test whether a list is empty.
Definition list.h:137
timer_init & pool
Definition pool.h:66
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition retry.c:65

References assert, list_add_tail, list_empty, pool, and start_timer_fixed().

Referenced by http_conn_xfer_close().

◆ pool_del()

void pool_del ( struct pooled_connection * pool)
extern

Remove connection from pool.

Parameters
poolPooled connection

Definition at line 83 of file pool.c.

83 {
84
85 /* Remove from list of pooled connections */
86 list_del ( &pool->list );
87 INIT_LIST_HEAD ( &pool->list );
88
89 /* Stop expiry timer */
90 stop_timer ( &pool->timer );
91
92 /* Mark as a freshly recycled connection */
93 pool->flags = POOL_RECYCLED;
94}
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition list.h:46
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition retry.c:118

References INIT_LIST_HEAD, list_del, pool, POOL_RECYCLED, and stop_timer().

Referenced by http_conn_close(), and http_connect().

◆ pool_expired()

void pool_expired ( struct retry_timer * timer,
int over __unused )
extern

Close expired pooled connection.

Parameters
timerExpiry timer
overFailure indicator

Definition at line 102 of file pool.c.

102 {
103 struct pooled_connection *pool =
105
106 /* Sanity check */
107 assert ( ! list_empty ( &pool->list ) );
108
109 /* Remove from connection pool */
110 list_del ( &pool->list );
111 INIT_LIST_HEAD ( &pool->list );
112
113 /* Close expired connection */
114 pool->expired ( pool );
115}
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
A pooled connection.
Definition pool.h:18
A timer.
Definition timer.h:29

References __unused, assert, container_of, INIT_LIST_HEAD, list_del, list_empty, and pool.

◆ __attribute__()

__attribute__ ( (always_inline) )
inlinestatic

Initialise a pooled connection.

Check if pooled connection is reopenable.

Check if pooled connection is recyclable.

Mark pooled connection as alive.

Mark pooled connection as recyclable.

Parameters
poolPooled connection
expiredClose expired pooled connection method
refcntContaining object reference counter
poolPooled connection
poolPooled connection
Return values
recyclablePooled connection is recyclable
Parameters
poolPooled connection
Return values
reopenablePooled connection is reopenable

Definition at line 75 of file pool.h.

76 {
77
78 pool->flags |= POOL_RECYCLABLE;
79}

References pool, and POOL_RECYCLABLE.

◆ pool_recycle()

void pool_recycle ( struct interface * intf)
extern

Recycle this connection after closing.

Parameters
intfData transfer interface

Definition at line 42 of file pool.c.

42 {
43
44 intf_poke ( intf, pool_recycle );
45}
void intf_poke(struct interface *intf, void(type)(struct interface *intf))
Poke an object interface.
Definition interface.c:421
void pool_recycle(struct interface *intf)
Recycle this connection after closing.
Definition pool.c:42

References intf_poke(), and pool_recycle().

Referenced by http_transfer_complete(), and pool_recycle().

◆ pool_reopen()

void pool_reopen ( struct interface * intf)
extern

Reopen a defunct connection.

Parameters
intfData transfer interface

Definition at line 52 of file pool.c.

52 {
53
54 intf_poke ( intf, pool_reopen );
55}
void pool_reopen(struct interface *intf)
Reopen a defunct connection.
Definition pool.c:52

References intf_poke(), and pool_reopen().

Referenced by http_conn_socket_close(), and pool_reopen().

Variable Documentation

◆ expired

pool expired ( struct pooled_connection * pool) = expired

Definition at line 62 of file pool.h.

Referenced by ib_mi_timer_expired().

◆ refcnt

timer refcnt
Initial value:
{
INIT_LIST_HEAD ( &pool->list )

Definition at line 63 of file pool.h.

◆ pool

timer_init & pool

Definition at line 66 of file pool.h.

Referenced by __attribute__(), http_conn_expired(), http_connect(), pool_add(), pool_del(), and pool_expired().