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:
Dodji Seketeli 2007-08-31 14:43:39 +02:00
parent 4dd4be99df
commit 9e192d2118
2 changed files with 37 additions and 19 deletions

View File

@ -368,7 +368,7 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
EPHYR_LOG_ERROR ("failed to query string from host\n") ;
goto out ;
}
EPHYR_LOG ("string: %s", server_string) ;
EPHYR_LOG ("string: %s\n", server_string) ;
length= strlen (server_string) + 1;
reply.type = X_Reply ;
reply.sequenceNumber = client->sequence ;
@ -577,8 +577,8 @@ ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
goto out ;
}
if (string) {
length = strlen (string) ;
EPHYR_LOG ("got string: string:%s\n", string) ;
length = strlen (string) + 1;
EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ;
} else {
EPHYR_LOG ("got string: string (null)\n") ;
}
@ -593,7 +593,7 @@ ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
res = Success ;
out:
EPHYR_LOG ("enter\n") ;
EPHYR_LOG ("leave\n") ;
return res ;
}
@ -619,6 +619,8 @@ ephyrGLXGetIntegervReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
GLint answer_buf_room[200];
GLint *buf=NULL ;
EPHYR_LOG ("enter\n") ;
a_pc += __GLX_SINGLE_HDR_SIZE;
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) ;
res = Success ;
out:
EPHYR_LOG ("leave\n") ;
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_LOG ("enter\n") ;
memset (&reply, 0, sizeof (reply)) ;
if (!ephyrHostIsContextDirect (req->context, (int*)&is_direct)) {
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;
WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
res = Success ;
out:
EPHYR_LOG ("leave\n") ;
return res ;
}

View File

@ -172,20 +172,26 @@ ephyrHostGLXGetStringFromServer (int a_screen_number,
length = reply.length * 4;
numbytes = reply.size;
EPHYR_LOG ("got a string of size:%d\n", numbytes) ;
*a_string = (char *) Xmalloc( numbytes );
if (*a_string != NULL) {
if (_XRead (dpy, *a_string, numbytes)) {
UnlockDisplay (dpy);
SyncHandle ();
EPHYR_LOG_ERROR ("read failed\n") ;
goto out ;
}
length -= numbytes;
*a_string = (char *) Xmalloc (numbytes +1);
if (!a_string) {
EPHYR_LOG_ERROR ("allocation failed\n") ;
goto out;
}
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) ;
UnlockDisplay (dpy);
SyncHandle ();
EPHYR_LOG ("string:'%s'\n", *a_string) ;
is_ok = TRUE ;
out:
@ -387,11 +393,12 @@ ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
req->numbytes = size;
Data (dpy, a_extension_list, size);
UnlockDisplay(dpy);
SyncHandle();
is_ok=TRUE ;
out:
UnlockDisplay(dpy);
SyncHandle();
return is_ok ;
}
@ -433,11 +440,12 @@ ephyrHostGLXCreateContext (int a_screen,
req->shareList = a_share_list_ctxt_id;
req->isDirect = a_direct;
UnlockDisplay (dpy);
SyncHandle ();
is_ok = TRUE ;
out:
UnlockDisplay (dpy);
SyncHandle ();
EPHYR_LOG ("leave\n") ;
return is_ok ;
}
@ -516,14 +524,16 @@ ephyrHostGLXMakeCurrent (int a_drawable,
memset (&reply, 0, sizeof (reply)) ;
if (!_XReply (dpy, (xReply*)&reply, 0, False)) {
EPHYR_LOG_ERROR ("failed to get reply from host\n") ;
UnlockDisplay (dpy);
SyncHandle ();
goto out ;
}
UnlockDisplay (dpy);
SyncHandle ();
*a_ctxt_tag = reply.contextTag ;
is_ok = TRUE ;
out:
UnlockDisplay (dpy);
SyncHandle ();
EPHYR_LOG ("leave\n") ;
return is_ok ;
}