Make all public functions do nothing on an error connection.
This commit is contained in:
parent
0aa96bfc7a
commit
7f71bf9c0f
|
@ -179,12 +179,16 @@ static int write_vec(XCBConnection *c, struct iovec **vector, int *count)
|
||||||
|
|
||||||
const XCBSetup *XCBGetSetup(XCBConnection *c)
|
const XCBSetup *XCBGetSetup(XCBConnection *c)
|
||||||
{
|
{
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
/* doesn't need locking because it's never written to. */
|
/* doesn't need locking because it's never written to. */
|
||||||
return c->setup;
|
return c->setup;
|
||||||
}
|
}
|
||||||
|
|
||||||
int XCBGetFileDescriptor(XCBConnection *c)
|
int XCBGetFileDescriptor(XCBConnection *c)
|
||||||
{
|
{
|
||||||
|
if(c->has_error)
|
||||||
|
return -1;
|
||||||
/* doesn't need locking because it's never written to. */
|
/* doesn't need locking because it's never written to. */
|
||||||
return c->fd;
|
return c->fd;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +229,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info)
|
||||||
|
|
||||||
void XCBDisconnect(XCBConnection *c)
|
void XCBDisconnect(XCBConnection *c)
|
||||||
{
|
{
|
||||||
if(!c)
|
if(c->has_error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
free(c->setup);
|
free(c->setup);
|
||||||
|
|
|
@ -84,6 +84,8 @@ static lazyreply *get_lazyreply(XCBConnection *c, XCBExtension *ext)
|
||||||
const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext)
|
const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext)
|
||||||
{
|
{
|
||||||
lazyreply *data;
|
lazyreply *data;
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&c->ext.lock);
|
pthread_mutex_lock(&c->ext.lock);
|
||||||
data = get_lazyreply(c, ext);
|
data = get_lazyreply(c, ext);
|
||||||
|
@ -99,6 +101,8 @@ const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *
|
||||||
|
|
||||||
void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext)
|
void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext)
|
||||||
{
|
{
|
||||||
|
if(c->has_error)
|
||||||
|
return;
|
||||||
pthread_mutex_lock(&c->ext.lock);
|
pthread_mutex_lock(&c->ext.lock);
|
||||||
get_lazyreply(c, ext);
|
get_lazyreply(c, ext);
|
||||||
pthread_mutex_unlock(&c->ext.lock);
|
pthread_mutex_unlock(&c->ext.lock);
|
||||||
|
|
40
src/xcb_in.c
40
src/xcb_in.c
|
@ -308,6 +308,8 @@ void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **
|
||||||
void *ret = 0;
|
void *ret = 0;
|
||||||
if(e)
|
if(e)
|
||||||
*e = 0;
|
*e = 0;
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&c->iolock);
|
pthread_mutex_lock(&c->iolock);
|
||||||
|
|
||||||
|
@ -356,6 +358,13 @@ void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **
|
||||||
int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error)
|
int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
if(c->has_error)
|
||||||
|
{
|
||||||
|
*reply = 0;
|
||||||
|
if(error)
|
||||||
|
*error = 0;
|
||||||
|
return 1; /* would not block */
|
||||||
|
}
|
||||||
assert(reply != 0);
|
assert(reply != 0);
|
||||||
pthread_mutex_lock(&c->iolock);
|
pthread_mutex_lock(&c->iolock);
|
||||||
ret = poll_for_reply(c, request, reply, error);
|
ret = poll_for_reply(c, request, reply, error);
|
||||||
|
@ -366,6 +375,8 @@ int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGen
|
||||||
XCBGenericEvent *XCBWaitForEvent(XCBConnection *c)
|
XCBGenericEvent *XCBWaitForEvent(XCBConnection *c)
|
||||||
{
|
{
|
||||||
XCBGenericEvent *ret;
|
XCBGenericEvent *ret;
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
pthread_mutex_lock(&c->iolock);
|
pthread_mutex_lock(&c->iolock);
|
||||||
/* get_event returns 0 on empty list. */
|
/* get_event returns 0 on empty list. */
|
||||||
while(!(ret = get_event(c)))
|
while(!(ret = get_event(c)))
|
||||||
|
@ -379,19 +390,22 @@ XCBGenericEvent *XCBWaitForEvent(XCBConnection *c)
|
||||||
|
|
||||||
XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error)
|
XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error)
|
||||||
{
|
{
|
||||||
XCBGenericEvent *ret = 0;
|
if(!c->has_error)
|
||||||
int success;
|
|
||||||
pthread_mutex_lock(&c->iolock);
|
|
||||||
/* FIXME: follow X meets Z architecture changes. */
|
|
||||||
success = _xcb_in_read(c);
|
|
||||||
if(success)
|
|
||||||
ret = get_event(c);
|
|
||||||
pthread_mutex_unlock(&c->iolock);
|
|
||||||
if(success)
|
|
||||||
{
|
{
|
||||||
if(error)
|
XCBGenericEvent *ret = 0;
|
||||||
*error = 0;
|
int success;
|
||||||
return ret;
|
pthread_mutex_lock(&c->iolock);
|
||||||
|
/* FIXME: follow X meets Z architecture changes. */
|
||||||
|
success = _xcb_in_read(c);
|
||||||
|
if(success)
|
||||||
|
ret = get_event(c);
|
||||||
|
pthread_mutex_unlock(&c->iolock);
|
||||||
|
if(success)
|
||||||
|
{
|
||||||
|
if(error)
|
||||||
|
*error = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(error)
|
if(error)
|
||||||
*error = -1;
|
*error = -1;
|
||||||
|
@ -410,6 +424,8 @@ XCBGenericError *XCBRequestCheck(XCBConnection *c, XCBVoidCookie cookie)
|
||||||
* XCBGetInputFocusReply, and XCBWaitForReply. */
|
* XCBGetInputFocusReply, and XCBWaitForReply. */
|
||||||
XCBGenericError *ret;
|
XCBGenericError *ret;
|
||||||
void *reply;
|
void *reply;
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
if(XCB_SEQUENCE_COMPARE(cookie.sequence,>,c->in.request_expected)
|
if(XCB_SEQUENCE_COMPARE(cookie.sequence,>,c->in.request_expected)
|
||||||
&& XCB_SEQUENCE_COMPARE(cookie.sequence,>,c->in.request_completed))
|
&& XCB_SEQUENCE_COMPARE(cookie.sequence,>,c->in.request_completed))
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,6 +59,8 @@ static int write_block(XCBConnection *c, struct iovec *vector, int count)
|
||||||
|
|
||||||
CARD32 XCBGetMaximumRequestLength(XCBConnection *c)
|
CARD32 XCBGetMaximumRequestLength(XCBConnection *c)
|
||||||
{
|
{
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
pthread_mutex_lock(&c->out.reqlenlock);
|
pthread_mutex_lock(&c->out.reqlenlock);
|
||||||
if(!c->out.maximum_request_length)
|
if(!c->out.maximum_request_length)
|
||||||
{
|
{
|
||||||
|
@ -91,6 +93,9 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c
|
||||||
int veclen = req->count;
|
int veclen = req->count;
|
||||||
enum workarounds workaround = WORKAROUND_NONE;
|
enum workarounds workaround = WORKAROUND_NONE;
|
||||||
|
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
|
|
||||||
assert(c != 0);
|
assert(c != 0);
|
||||||
assert(vector != 0);
|
assert(vector != 0);
|
||||||
assert(req->count > 0);
|
assert(req->count > 0);
|
||||||
|
@ -200,6 +205,8 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c
|
||||||
int XCBFlush(XCBConnection *c)
|
int XCBFlush(XCBConnection *c)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
pthread_mutex_lock(&c->iolock);
|
pthread_mutex_lock(&c->iolock);
|
||||||
ret = _xcb_out_flush_to(c, c->out.request);
|
ret = _xcb_out_flush_to(c, c->out.request);
|
||||||
pthread_mutex_unlock(&c->iolock);
|
pthread_mutex_unlock(&c->iolock);
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
CARD32 XCBGenerateID(XCBConnection *c)
|
CARD32 XCBGenerateID(XCBConnection *c)
|
||||||
{
|
{
|
||||||
CARD32 ret;
|
CARD32 ret;
|
||||||
|
if(c->has_error)
|
||||||
|
return -1;
|
||||||
pthread_mutex_lock(&c->xid.lock);
|
pthread_mutex_lock(&c->xid.lock);
|
||||||
if(c->xid.last == c->xid.max)
|
if(c->xid.last == c->xid.max)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,10 +28,14 @@
|
||||||
|
|
||||||
unsigned int XCBGetRequestSent(XCBConnection *c)
|
unsigned int XCBGetRequestSent(XCBConnection *c)
|
||||||
{
|
{
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
return c->out.request;
|
return c->out.request;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_t *XCBGetIOLock(XCBConnection *c)
|
pthread_mutex_t *XCBGetIOLock(XCBConnection *c)
|
||||||
{
|
{
|
||||||
|
if(c->has_error)
|
||||||
|
return 0;
|
||||||
return &c->iolock;
|
return &c->iolock;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue