Xephyr: better error handling in GLX forwarding
* hw/kdrive/ephyr/ephyrglxext.c: fixed various logging functions (ephyrGLXGetStringReal): make sure all the string is sent to clients including the ending zero. * hw/kdrive/ephyr/ephyrhostglx.c: (ephyrHostGLXGetStringFromServer): better error handling. (ephyrHostGLXSendClientInfo): ditto. (ephyrHostGLXMakeCurrent): ditto
This commit is contained in:
parent
4dd4be99df
commit
9e192d2118
|
@ -368,7 +368,7 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
|
||||||
EPHYR_LOG_ERROR ("failed to query string from host\n") ;
|
EPHYR_LOG_ERROR ("failed to query string from host\n") ;
|
||||||
goto out ;
|
goto out ;
|
||||||
}
|
}
|
||||||
EPHYR_LOG ("string: %s", server_string) ;
|
EPHYR_LOG ("string: %s\n", server_string) ;
|
||||||
length= strlen (server_string) + 1;
|
length= strlen (server_string) + 1;
|
||||||
reply.type = X_Reply ;
|
reply.type = X_Reply ;
|
||||||
reply.sequenceNumber = client->sequence ;
|
reply.sequenceNumber = client->sequence ;
|
||||||
|
@ -577,8 +577,8 @@ ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||||
goto out ;
|
goto out ;
|
||||||
}
|
}
|
||||||
if (string) {
|
if (string) {
|
||||||
length = strlen (string) ;
|
length = strlen (string) + 1;
|
||||||
EPHYR_LOG ("got string: string:%s\n", string) ;
|
EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ;
|
||||||
} else {
|
} else {
|
||||||
EPHYR_LOG ("got string: string (null)\n") ;
|
EPHYR_LOG ("got string: string (null)\n") ;
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||||
|
|
||||||
res = Success ;
|
res = Success ;
|
||||||
out:
|
out:
|
||||||
EPHYR_LOG ("enter\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,6 +619,8 @@ ephyrGLXGetIntegervReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||||
GLint answer_buf_room[200];
|
GLint answer_buf_room[200];
|
||||||
GLint *buf=NULL ;
|
GLint *buf=NULL ;
|
||||||
|
|
||||||
|
EPHYR_LOG ("enter\n") ;
|
||||||
|
|
||||||
a_pc += __GLX_SINGLE_HDR_SIZE;
|
a_pc += __GLX_SINGLE_HDR_SIZE;
|
||||||
|
|
||||||
int_name = *(GLenum*) (a_pc+0) ;
|
int_name = *(GLenum*) (a_pc+0) ;
|
||||||
|
@ -638,7 +640,9 @@ ephyrGLXGetIntegervReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||||
}
|
}
|
||||||
__glXSendReply (a_cl->client, buf, 1, sizeof (value), GL_FALSE, 0) ;
|
__glXSendReply (a_cl->client, buf, 1, sizeof (value), GL_FALSE, 0) ;
|
||||||
res = Success ;
|
res = Success ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
EPHYR_LOG ("leave\n") ;
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,6 +669,8 @@ ephyrGLXIsDirectReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||||
|
|
||||||
EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, FALSE) ;
|
EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, FALSE) ;
|
||||||
|
|
||||||
|
EPHYR_LOG ("enter\n") ;
|
||||||
|
|
||||||
memset (&reply, 0, sizeof (reply)) ;
|
memset (&reply, 0, sizeof (reply)) ;
|
||||||
if (!ephyrHostIsContextDirect (req->context, (int*)&is_direct)) {
|
if (!ephyrHostIsContextDirect (req->context, (int*)&is_direct)) {
|
||||||
EPHYR_LOG_ERROR ("ephyrHostIsContextDirect() failed\n") ;
|
EPHYR_LOG_ERROR ("ephyrHostIsContextDirect() failed\n") ;
|
||||||
|
@ -676,7 +682,9 @@ ephyrGLXIsDirectReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||||
reply.sequenceNumber = client->sequence;
|
reply.sequenceNumber = client->sequence;
|
||||||
WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
|
WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
|
||||||
res = Success ;
|
res = Success ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
EPHYR_LOG ("leave\n") ;
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,20 +172,26 @@ ephyrHostGLXGetStringFromServer (int a_screen_number,
|
||||||
|
|
||||||
length = reply.length * 4;
|
length = reply.length * 4;
|
||||||
numbytes = reply.size;
|
numbytes = reply.size;
|
||||||
|
EPHYR_LOG ("got a string of size:%d\n", numbytes) ;
|
||||||
|
|
||||||
*a_string = (char *) Xmalloc( numbytes );
|
*a_string = (char *) Xmalloc (numbytes +1);
|
||||||
if (*a_string != NULL) {
|
if (!a_string) {
|
||||||
if (_XRead (dpy, *a_string, numbytes)) {
|
EPHYR_LOG_ERROR ("allocation failed\n") ;
|
||||||
UnlockDisplay (dpy);
|
goto out;
|
||||||
SyncHandle ();
|
|
||||||
EPHYR_LOG_ERROR ("read failed\n") ;
|
|
||||||
goto out ;
|
|
||||||
}
|
|
||||||
length -= numbytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset (*a_string, 0, numbytes+1) ;
|
||||||
|
if (_XRead (dpy, *a_string, numbytes)) {
|
||||||
|
UnlockDisplay (dpy);
|
||||||
|
SyncHandle ();
|
||||||
|
EPHYR_LOG_ERROR ("read failed\n") ;
|
||||||
|
goto out ;
|
||||||
|
}
|
||||||
|
length -= numbytes;
|
||||||
_XEatData (dpy, length) ;
|
_XEatData (dpy, length) ;
|
||||||
UnlockDisplay (dpy);
|
UnlockDisplay (dpy);
|
||||||
SyncHandle ();
|
SyncHandle ();
|
||||||
|
EPHYR_LOG ("string:'%s'\n", *a_string) ;
|
||||||
|
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
out:
|
out:
|
||||||
|
@ -387,11 +393,12 @@ ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
|
||||||
req->numbytes = size;
|
req->numbytes = size;
|
||||||
Data (dpy, a_extension_list, size);
|
Data (dpy, a_extension_list, size);
|
||||||
|
|
||||||
|
UnlockDisplay(dpy);
|
||||||
|
SyncHandle();
|
||||||
|
|
||||||
is_ok=TRUE ;
|
is_ok=TRUE ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
UnlockDisplay(dpy);
|
|
||||||
SyncHandle();
|
|
||||||
return is_ok ;
|
return is_ok ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,11 +440,12 @@ ephyrHostGLXCreateContext (int a_screen,
|
||||||
req->shareList = a_share_list_ctxt_id;
|
req->shareList = a_share_list_ctxt_id;
|
||||||
req->isDirect = a_direct;
|
req->isDirect = a_direct;
|
||||||
|
|
||||||
|
UnlockDisplay (dpy);
|
||||||
|
SyncHandle ();
|
||||||
|
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
UnlockDisplay (dpy);
|
|
||||||
SyncHandle ();
|
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
return is_ok ;
|
return is_ok ;
|
||||||
}
|
}
|
||||||
|
@ -516,14 +524,16 @@ ephyrHostGLXMakeCurrent (int a_drawable,
|
||||||
memset (&reply, 0, sizeof (reply)) ;
|
memset (&reply, 0, sizeof (reply)) ;
|
||||||
if (!_XReply (dpy, (xReply*)&reply, 0, False)) {
|
if (!_XReply (dpy, (xReply*)&reply, 0, False)) {
|
||||||
EPHYR_LOG_ERROR ("failed to get reply from host\n") ;
|
EPHYR_LOG_ERROR ("failed to get reply from host\n") ;
|
||||||
|
UnlockDisplay (dpy);
|
||||||
|
SyncHandle ();
|
||||||
goto out ;
|
goto out ;
|
||||||
}
|
}
|
||||||
|
UnlockDisplay (dpy);
|
||||||
|
SyncHandle ();
|
||||||
*a_ctxt_tag = reply.contextTag ;
|
*a_ctxt_tag = reply.contextTag ;
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
UnlockDisplay (dpy);
|
|
||||||
SyncHandle ();
|
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
return is_ok ;
|
return is_ok ;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue