iPXE
Functions
pool.c File Reference

Pooled connections. More...

#include <assert.h>
#include <ipxe/pool.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void pool_recycle (struct interface *intf)
 Recycle this connection after closing. More...
 
void pool_reopen (struct interface *intf)
 Reopen a defunct connection. More...
 
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 __unused)
 Close expired pooled connection. More...
 

Detailed Description

Pooled connections.

Definition in file pool.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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:397

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:397

References intf_poke(), and pool_reopen().

Referenced by http_conn_socket_close(), and pool_reopen().

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