iPXE
Data Structures | Macros | 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...
 

Macros

#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. More...
 
void pool_del (struct pooled_connection *pool)
 Remove connection from pool. More...
 
void pool_expired (struct retry_timer *timer, int over)
 Close expired pooled connection. More...
 
static __attribute__ ((always_inline)) void pool_init(struct pooled_connection *pool
 Initialise a pooled connection. More...
 
void pool_recycle (struct interface *intf)
 Recycle this connection after closing. More...
 
void pool_reopen (struct interface *intf)
 Reopen a defunct connection. More...
 

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)    typeof ( void ( object_type ) )

Definition at line 120 of file pool.h.

◆ pool_reopen_TYPE

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

Definition at line 124 of file pool.h.

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

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

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pool_add()

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.

64  {
65 
66  /* Sanity check */
67  assert ( list_empty ( &pool->list ) );
68  assert ( ! timer_running ( &pool->timer ) );
69 
70  /* Add to list of pooled connections */
71  list_add_tail ( &pool->list, list );
72 
73  /* Start expiry timer */
74  start_timer_fixed ( &pool->timer, expiry );
75 }
timer_init & pool
Definition: pool.h:65
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64

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)

Remove connection from pool.

Parameters
poolPooled connection

Definition at line 82 of file pool.c.

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

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 
)

Close expired pooled connection.

Parameters
timerExpiry timer
overFailure indicator

Definition at line 101 of file pool.c.

101  {
102  struct pooled_connection *pool =
104 
105  /* Sanity check */
106  assert ( ! list_empty ( &pool->list ) );
107 
108  /* Remove from connection pool */
109  list_del ( &pool->list );
110  INIT_LIST_HEAD ( &pool->list );
111 
112  /* Close expired connection */
113  pool->expired ( pool );
114 }
timer_init & pool
Definition: pool.h:65
A pooled connection.
Definition: pool.h:17
A timer.
Definition: timer.h:28
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45

References assert(), container_of, INIT_LIST_HEAD, list_del, list_empty, and pool.

◆ __attribute__()

static __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 74 of file pool.h.

75  {
76 
77  pool->flags |= POOL_RECYCLABLE;
78 }
timer_init & pool
Definition: pool.h:65
Connection should be recycled after closing.
Definition: pool.h:40

References pool, and POOL_RECYCLABLE.

◆ pool_recycle()

void pool_recycle ( struct interface intf)

Recycle this connection after closing.

Parameters
intfData transfer interface

Definition at line 41 of file pool.c.

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

References intf_poke(), and pool_recycle().

Referenced by http_transfer_complete(), and pool_recycle().

◆ pool_reopen()

void pool_reopen ( struct interface intf)

Reopen a defunct connection.

Parameters
intfData transfer interface

Definition at line 51 of file pool.c.

51  {
52 
53  intf_poke ( intf, pool_reopen );
54 }
void pool_reopen(struct interface *intf)
Reopen a defunct connection.
Definition: pool.c:51
void intf_poke(struct interface *intf, void(type)(struct interface *intf))
Poke an object interface.
Definition: interface.c:420

References intf_poke(), and pool_reopen().

Referenced by http_conn_socket_close(), and pool_reopen().

Variable Documentation

◆ expired

pool expired = expired

Definition at line 61 of file pool.h.

Referenced by ib_mi_timer_expired().

◆ refcnt

Initial value:
{
INIT_LIST_HEAD ( &pool->list )
timer_init & pool
Definition: pool.h:65
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45

Definition at line 62 of file pool.h.

Referenced by acpi_init(), fc_ulp_user_init(), intf_init(), process_init_stopped(), and settings_init().

◆ pool

timer_init & pool

Definition at line 65 of file pool.h.

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