| OpenSS7 SS7 for the Common Man | © Copyright 1997-2007 OpenSS7 Corporation All Rights Reserved. Last modified: Sat, 01 Nov 2008 10:41:53 GMT | ||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| Description: Manual PageKeywords: ss7 ss7/ip ss7 over ip ss7 mtp ss7 sccp ss7 tcap sigtran mtp sccp tcap openss7 acb56 linux telephony pstn linux telephony linux nebs linux compactpciBUFCALLSection: Linux Fast-STREAMS DDI/DKI (9)Updated: 2008-10-31 Index Return to Main Contents NAMEbufcall - install a buffer callbackSYNOPSIS#include <sys/stream.h>
ARGUMENTS
INTERFACEDESCRIPTIONWhen allocation of a buffer fails as a result of a failed call to allocb(9), the qi_srvp(9) procedure should place the message that invoked the allocb(9) call back on the queue with putbq(9) and call the bufcall() function with the queue's qi_srvp(9) procedure as the func argument and a pointer to the queue as the arg argument to the call. The size and pri arguments should be the same as the size and pri arguments that were issued to allocb(9). In this way, the queue qi_srvp(9) procedure will be recalled once there is sufficient memory to allocate the requested buffer and message blocks. RETURNbufcall() returns a bcid_t defined as follows: typedef int bcid_t; typedef int bufcall_id_t; Upon success, bufcall() returns a non-zero bufcall id and the specified func will be called with the specified arg at a later time when buffers of the necessary size become available. Upon failure, bufcall() returns zero (0) and no call will be generated to the specified func. ERRORSWhen bufcall() encounters an error, it returns zero (0). bufcall() returns zero (0) when the function pointer to the callback function, func is NULL, or bufcall() cannot allocate the necessary internal structures. CONTEXTbufcall() can be called from any context, including user context, qi_qopen(9), qi_qclose(9), qi_putp(9), qi_srvp(9) procedures, bufcall(9), qbufcall(9), timeout(9), qtimeout(9) callbacks, and interrupt service routines. MP-STREAMSbufcall() is MP-safe. Considerations should be given when writing the callback function that a bufcall() callback function could execute at the same time as any qi_qopen(9), qi_qclose(9), qi_putp(9), or qi_srvp(9) procedure, bufcall(9), qbufcall(9), timeout(9), qtimeout(9) callback or interrupt service routine. Nevertheless, the bufcall() callback function will be serviced by the same thread as the thread from which the bufcall() was issued. Therefore, the callback function will not execute until after bufcall() returns. Because the servicing thread and the current thread are the same, the bufcall() callback will not be invoked until after the function that called bufcall() returns. This means that it is safe to store the returned bufcall id in global variables accessed by the callback function. This is the same situation for qtimeout(9), qbufcall(9), timeout(9), bufcall(9) and esbbcall(9) functions. However, if the bufcall() was generated from a qi_qopen(9), qi_qclose(9), qi_putp(9) or qi_srvp(9) procedure, or was generated from within a mi_bufcall(9), qbufcall(9), qtimeout(9), callback, or other queue referenced bufcall(), esbbcall(9), timeout(9), callback, then the STREAMS executive is aware of the queue to which the callback function is to be referenced and will generate a buffer call internally that is referenced against the queue within whose synchronization context the call was invoked. This makes the bufcall() function safer than the normal SVR 4.2 MP equivalent. See mp-streams(9) for additional information. NOTICESbcid_t and bufcall_id_t should be treated as an opaque type that can be tested to equality to zero. The value should not otherwise be manipulated. bufcall() implements bufcall id values internally as a compressed out dating pointer to a strevent structure containing the bufcall callback function and argument. On 64-bit architectures this value should not be stored as an int, nor converted to any integer type with less bits than a pointer. All outstanding buffer calls allocated with bufcall() must be cancelled with a call to unbufcall(9) before invalidating any of the references passed as an argument to the callback function. When the argument is a queue(9) pointer, all outstanding buffer calls must be cancelled with unbufcall(9) before the queue is deallocated (i.e. before returning from the qi_qclose(9)) procedure. EXAMPLESIt is typical to see bufcall() used to merely enable a queue from a qi_srvp(9) procedure as follows:
int xxx_srvp(queue_t *q)
{
mblk_t *mp, *dp;
while ((mp = get(q))) {
switch (mp->b_datap->db_type) {
case M_PROTO:
if ((dp = allocb(somesize, BPRI_MED)) == NULL) {
putbq(mp);
bufcall(somesize, BPRI_MED, (void *) qenable,
(long) q);
return (0);
}
...
}
}
return (0);
}
SEE ALSOputbq(9), allocb(9), unbufcall(9), qbufcall(9), qunbufcall(9), mp-streams(9), STREAMS(9). BUGSCOMPATIBILITYbufcall() is compatible with SVR 4.2 MP DDI/DKI[2], and systems based on SVR 4[3] with the folllowing portability considerations:
See STREAMS(9) for additional compatibility information. CONFORMANCEHISTORYbufcall() appears as part of SVR 4.0 STREAMS[3]. bufcall() first appeared in SVR 3[6]. REFERENCES
TRADEMARKS
Other trademarks are the property of their respective owners. IDENTIFICATION
Copyright©1997-2008OpenSS7 Corp.
All Rights Reserved.
Index
This document was created by man2html, using the manual pages. Time: 08:50:20 GMT, June 19, 2013 | ||||||||||||||||||||||||||||||||
| OpenSS7 SS7 for the Common Man |
| ||||||||||||||||||||||||||||||||
| Last modified: Sat, 01 Nov 2008 10:41:53 GMT © Copyright 1997-2007 OpenSS7 Corporation All Rights Reserved. | |||||||||||||||||||||||||||||||||