Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
f5606127
Commit
f5606127
authored
20 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
update for new thread interface.
parent
3895d546
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/zmapView/zmapView.c
+120
-84
120 additions, 84 deletions
src/zmapView/zmapView.c
with
120 additions
and
84 deletions
src/zmapView/zmapView.c
+
120
−
84
View file @
f5606127
...
...
@@ -25,16 +25,16 @@
* Description:
* Exported functions: See ZMap/zmapView.h
* HISTORY:
* Last edited:
Jan 20 11:53
2005 (edgrif)
* Last edited:
Feb 1 16:24
2005 (edgrif)
* Created: Thu May 13 15:28:26 2004 (edgrif)
* CVS info: $Id: zmapView.c,v 1.4
1
2005-0
1-24 11:49
:4
5
edgrif Exp $
* CVS info: $Id: zmapView.c,v 1.4
2
2005-0
2-02 14:52
:4
8
edgrif Exp $
*-------------------------------------------------------------------
*/
#include
<gtk/gtk.h>
#include
<ZMap/zmapUtils.h>
#include
<ZMap/zmapConfig.h>
#include
<ZMap/zmap
Conn
.h>
#include
<ZMap/zmap
ServerProtocol
.h>
#include
<ZMap/zmapWindow.h>
#include
<zmapView_P.h>
...
...
@@ -74,7 +74,7 @@ static ZMapViewConnection createConnection(ZMapView zmap_view,
char
*
machine
,
int
port
,
char
*
protocol
,
int
timeout
,
char
*
version
,
char
*
types_file
,
gboolean
sequence_server
,
gboolean
writeback_server
,
char
*
sequence
,
int
start
,
int
end
,
gboolean
load_features
)
;
char
*
sequence
,
int
start
,
int
end
)
;
static
void
destroyConnection
(
ZMapViewConnection
*
view_conn
)
;
static
void
resetWindows
(
ZMapView
zmap_view
)
;
...
...
@@ -87,7 +87,7 @@ static void destroyWindow(ZMapView zmap_view, ZMapViewWindow view_window) ;
static
void
freeContext
(
ZMapFeatureContext
feature_context
)
;
static
void
getFeatures
(
ZMapView
zmap_view
,
ZMap
ProtocolAny
req_any
)
;
static
void
getFeatures
(
ZMapView
zmap_view
,
ZMap
ServerReqGetFeatures
feature_req
)
;
...
...
@@ -156,8 +156,8 @@ ZMapView zMapViewCreate(char *sequence, int start, int end, void *app_data)
/* Set up debugging for threads, we do it here so that user can change setting in config file
* and next time they create a view the debugging will go on/off. */
if
(
zMapUtilsConfigDebug
(
ZMAPTHR_CONFIG_DEBUG_STR
,
&
debug
))
zmap_thr_debug_G
=
debug
;
if
(
zMapUtilsConfigDebug
(
ZMAPTHR
EAD
_CONFIG_DEBUG_STR
,
&
debug
))
zmap_thr
ead
_debug_G
=
debug
;
zmap_view
=
createZMapView
(
sequence
,
start
,
end
,
app_data
)
;
...
...
@@ -222,7 +222,6 @@ ZMapViewWindow zMapViewCopyWindow(ZMapView zmap_view, GtkWidget *parent_widget,
ZMapWindow
copy_window
)
{
ZMapViewWindow
view_window
=
NULL
;
double
zoom_factor
;
/* the view _must_ already have a window. */
zMapAssert
(
zmap_view
&&
parent_widget
...
...
@@ -309,9 +308,6 @@ gboolean zMapViewConnect(ZMapView zmap_view)
{
ZMapConfig
config
;
/* this should be user settable.... */
gboolean
load_features
=
TRUE
;
zmapViewBusy
(
zmap_view
,
TRUE
)
;
/* We need to retrieve the connect data here from the config stuff.... */
...
...
@@ -393,8 +389,7 @@ gboolean zMapViewConnect(ZMapView zmap_view)
timeout
,
version
,
types_file
,
sequence_server
,
writeback_server
,
zmap_view
->
sequence
,
zmap_view
->
start
,
zmap_view
->
end
,
load_features
)))
zmap_view
->
start
,
zmap_view
->
end
)))
{
/* Update now we have successfully created a connection. */
zmap_view
->
connection_list
=
g_list_append
(
zmap_view
->
connection_list
,
view_con
)
;
...
...
@@ -441,9 +436,6 @@ gboolean zMapViewConnect(ZMapView zmap_view)
zmap_view
->
state
=
ZMAPVIEW_NOT_CONNECTED
;
}
/* If we are loading features then we need to visually tell the user we are doing this. */
if
(
!
load_features
)
zmapViewBusy
(
zmap_view
,
FALSE
)
;
}
return
result
;
...
...
@@ -932,16 +924,21 @@ static gboolean checkStateConnections(ZMapView zmap_view)
do
{
ZMapViewConnection
view_con
;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection
connection
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread
thread
;
ZMapThreadReply
reply
;
void
*
data
=
NULL
;
char
*
err_msg
=
NULL
;
view_con
=
list_item
->
data
;
connection
=
view_con
->
connection
;
thread
=
view_con
->
thread
;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMAP_DEBUG
(
"GUI: checking connection for thread %
x
\n
"
,
ZMAP_DEBUG
(
"GUI: checking connection for thread %
lu
\n
"
,
zMapConnGetThreadid
(
connection
))
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
...
...
@@ -953,10 +950,10 @@ static gboolean checkStateConnections(ZMapView zmap_view)
data
=
NULL
;
err_msg
=
NULL
;
if
(
!
(
zMap
Conn
GetReplyWithData
(
connection
,
&
reply
,
&
data
,
&
err_msg
)))
if
(
!
(
zMap
Thread
GetReplyWithData
(
thread
,
&
reply
,
&
data
,
&
err_msg
)))
{
zMapDebug
(
"GUI: thread %
x
, cannot access reply from thread - %s
\n
"
,
zMap
Conn
GetThreadid
(
connection
),
err_msg
)
;
zMapDebug
(
"GUI: thread %
lu
, cannot access reply from thread - %s
\n
"
,
zMap
Thread
GetThreadid
(
thread
),
err_msg
)
;
/* should abort or dump here....or at least kill this connection. */
...
...
@@ -965,45 +962,54 @@ static gboolean checkStateConnections(ZMapView zmap_view)
{
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
zMapDebug
(
"GUI: thread %
x
, thread reply = %s
\n
"
,
zMap
Conn
GetThreadid
(
connection
),
zMapDebug
(
"GUI: thread %
lu
, thread reply = %s
\n
"
,
zMap
Thread
GetThreadid
(
thread
),
zMapVarGetReplyString
(
reply
))
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
if
(
reply
==
ZMAP_REPLY_WAIT
)
if
(
reply
==
ZMAP
THREAD
_REPLY_WAIT
)
{
;
/* nothing to do. */
}
else
if
(
reply
==
ZMAP_REPLY_GOTDATA
)
else
if
(
reply
==
ZMAP
THREAD
_REPLY_GOTDATA
)
{
view_con
->
curr_request
=
ZMAP_REQUEST_WAIT
;
view_con
->
curr_request
=
ZMAP
THREAD
_REQUEST_WAIT
;
if
(
zmap_view
->
state
==
ZMAPVIEW_RUNNING
)
{
ZMap
Protocol
Any
req_any
=
(
ZMap
Protocol
Any
)
data
;
ZMap
ServerReq
Any
req_any
=
(
ZMap
ServerReq
Any
)
data
;
zMapDebug
(
"GUI: thread %
x
, got data
\n
"
,
zMap
Conn
GetThreadid
(
connection
))
;
zMapDebug
(
"GUI: thread %
lu
, got data
\n
"
,
zMap
Thread
GetThreadid
(
thread
))
;
/* Reset the reply from the slave. */
zMap
Conn
SetReply
(
connection
,
ZMAP
_REPLY_WAIT
)
;
zMap
Thread
SetReply
(
thread
,
ZMAPTHREAD
_REPLY_WAIT
)
;
/* Process the different types of data coming back. */
switch
(
req_any
->
request
)
switch
(
req_any
->
type
)
{
case
ZMAP_PROTOCOLREQUEST_FEATURES
:
case
ZMAP_PROTOCOLREQUEST_FEATURE_SEQUENCE
:
case
ZMAP_PROTOCOLREQUEST_SEQUENCE
:
case
ZMAP_SERVERREQ_OPENLOAD
:
{
ZMapServerReqGetFeatures
features
=
(
ZMapServerReqGetFeatures
)
&
(((
ZMapServerReqOpenLoad
)
req_any
)
->
features
)
;
getFeatures
(
zmap_view
,
features
)
;
break
;
}
case
ZMAP_SERVERREQ_FEATURES
:
case
ZMAP_SERVERREQ_FEATURE_SEQUENCE
:
case
ZMAP_SERVERREQ_SEQUENCE
:
{
getFeatures
(
zmap_view
,
req_any
)
;
getFeatures
(
zmap_view
,
(
ZMapServerReqGetFeatures
)
req_any
)
;
break
;
}
default:
{
zMapLogFatal
(
"Unknown request type: %d"
,
req_any
->
request
)
;
/* Exit appl. */
zMapLogFatal
(
"Unknown request type: %d"
,
req_any
->
type
)
;
/* Exit appl. */
break
;
}
}
...
...
@@ -1012,27 +1018,28 @@ static gboolean checkStateConnections(ZMapView zmap_view)
g_free
(
data
)
;
}
else
zMapDebug
(
"GUI: thread %x, got data but ZMap state is - %s
\n
"
,
zMapConnGetThreadid
(
connection
),
zMapViewGetStatus
(
zmap_view
))
;
zMapDebug
(
"GUI: thread %lu, got data but ZMap state is - %s
\n
"
,
zMapThreadGetThreadid
(
thread
),
zMapViewGetStatusStr
(
zMapViewGetStatus
(
zmap_view
)))
;
}
else
if
(
reply
==
ZMAP_REPLY_REQERROR
)
else
if
(
reply
==
ZMAP
THREAD
_REPLY_REQERROR
)
{
if
(
err_msg
)
zMapWarning
(
"%s"
,
err_msg
)
;
view_con
->
curr_request
=
ZMAP_REQUEST_WAIT
;
view_con
->
curr_request
=
ZMAP
THREAD
_REQUEST_WAIT
;
/* Reset the reply from the slave. */
zMap
Conn
SetReply
(
connection
,
ZMAP
_REPLY_WAIT
)
;
zMap
Thread
SetReply
(
thread
,
ZMAPTHREAD
_REPLY_WAIT
)
;
/* This means the request failed for some reason. */
zMapDebug
(
"GUI: thread %
x
, request to server failed....
\n
"
,
zMap
Conn
GetThreadid
(
connection
))
;
zMapDebug
(
"GUI: thread %
lu
, request to server failed....
\n
"
,
zMap
Thread
GetThreadid
(
thread
))
;
g_free
(
err_msg
)
;
}
else
if
(
reply
==
ZMAP_REPLY_DIED
)
else
if
(
reply
==
ZMAP
THREAD
_REPLY_DIED
)
{
if
(
err_msg
)
zMapWarning
(
"%s"
,
err_msg
)
;
...
...
@@ -1040,8 +1047,8 @@ static gboolean checkStateConnections(ZMapView zmap_view)
threads_have_died
=
TRUE
;
/* This means the thread has failed for some reason and we should clean up. */
zMapDebug
(
"GUI: thread %
x
has died so cleaning up....
\n
"
,
zMap
Conn
GetThreadid
(
connection
))
;
zMapDebug
(
"GUI: thread %
lu
has died so cleaning up....
\n
"
,
zMap
Thread
GetThreadid
(
thread
))
;
/* We are going to remove an item from the list so better move on from
* this item. */
...
...
@@ -1050,15 +1057,15 @@ static gboolean checkStateConnections(ZMapView zmap_view)
destroyConnection
(
&
view_con
)
;
}
else
if
(
reply
==
ZMAP_REPLY_CANCELLED
)
else
if
(
reply
==
ZMAP
THREAD
_REPLY_CANCELLED
)
{
/* I'm not sure we need to do anything here as now this loop is "inside" a
* zmap, we should already chopping the zmap threads outside of this routine,
* so I think logically this cannot happen...???? */
/* This means the thread was cancelled so we should clean up..... */
zMapDebug
(
"GUI: thread %
x
has been cancelled so cleaning up....
\n
"
,
zMap
Conn
GetThreadid
(
connection
))
;
zMapDebug
(
"GUI: thread %
lu
has been cancelled so cleaning up....
\n
"
,
zMap
Thread
GetThreadid
(
thread
))
;
/* We are going to remove an item from the list so better move on from
* this item. */
...
...
@@ -1156,21 +1163,26 @@ static void loadDataConnections(ZMapView zmap_view)
do
{
ZMapViewConnection
view_con
;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection
connection
;
ZMapProtocolGetFeatures
req_features
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread
thread
;
ZMapServerReqGetFeatures
req_features
;
view_con
=
list_item
->
data
;
connection
=
view_con
->
connection
;
thread
=
view_con
->
thread
;
/* Construct the request to get the features, if its the sequence server then
* get the sequence as well. */
req_features
=
g_new0
(
ZMap
Protocol
GetFeaturesStruct
,
1
)
;
req_features
=
g_new0
(
ZMap
ServerReq
GetFeaturesStruct
,
1
)
;
if
(
view_con
->
sequence_server
)
req_features
->
request
=
ZMAP_
PROTOCOLREQUEST
_FEATURE_SEQUENCE
;
req_features
->
type
=
ZMAP_
SERVERREQ
_FEATURE_SEQUENCE
;
else
req_features
->
request
=
ZMAP_
PROTOCOLREQUEST
_FEATURES
;
req_features
->
type
=
ZMAP_
SERVERREQ
_FEATURES
;
zMap
Conn
Request
(
connection
,
req_features
)
;
zMap
Thread
Request
(
thread
,
req_features
)
;
}
while
((
list_item
=
g_list_next
(
list_item
)))
;
}
...
...
@@ -1233,14 +1245,18 @@ static void killConnections(ZMapView zmap_view)
do
{
ZMapViewConnection
view_con
;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection
connection
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread
thread
;
view_con
=
list_item
->
data
;
connection
=
view_con
->
connection
;
thread
=
view_con
->
thread
;
/* NOTE, we do a _kill_ here, not a destroy. This just signals the thread to die, it
* will actually die sometime later. */
zMap
ConnKill
(
connection
)
;
zMap
ThreadKill
(
thread
)
;
}
while
((
list_item
=
g_list_next
(
list_item
)))
;
...
...
@@ -1248,38 +1264,64 @@ static void killConnections(ZMapView zmap_view)
}
/* Allocate a
nd destroy ZMapViews record of a connection
. */
/* Allocate a
connection and send over the request to get the sequence displayed
. */
static
ZMapViewConnection
createConnection
(
ZMapView
zmap_view
,
char
*
machine
,
int
port
,
char
*
protocol
,
int
timeout
,
char
*
version
,
char
*
types_file
,
gboolean
sequence_server
,
gboolean
writeback_server
,
char
*
sequence
,
int
start
,
int
end
,
gboolean
load_features
)
char
*
sequence
,
int
start
,
int
end
)
{
ZMapViewConnection
view_con
=
NULL
;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection
connection
;
ZMapProtocolGetFeatures
initial_request
=
NULL
;
GData
*
types
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread
thread
;
/*
If we need to autoload features
the
n
con
struct an initial request
that will
be given
* to
the thread to get the features and maybe the sequence
. */
if
(
load_features
)
/*
Create the thread to service
the con
nection requests, we give it a function
that
it
will
call
* to
decode the requests we send it
. */
if
(
(
thread
=
zMapThreadCreate
(
zMapServerRequestHandler
))
)
{
initial_request
=
g_new0
(
ZMapProtocolGetFeaturesStruct
,
1
)
;
ZMapServerReqOpenLoad
open_load
=
NULL
;
GData
*
types
;
/* in the end the types files will be optional..... */
types
=
zMapFeatureTypeGetFromFile
(
types_file
)
;
/* Build the intial request. */
open_load
=
g_new0
(
ZMapServerReqOpenLoadStruct
,
1
)
;
open_load
->
type
=
ZMAP_SERVERREQ_OPENLOAD
;
open_load
->
open
.
machine
=
g_strdup
(
machine
)
;
open_load
->
open
.
port
=
port
;
open_load
->
open
.
protocol
=
g_strdup
(
protocol
)
;
open_load
->
open
.
timeout
=
timeout
;
open_load
->
open
.
version
=
g_strdup
(
version
)
;
open_load
->
context
.
sequence
=
g_strdup
(
sequence
)
;
open_load
->
context
.
start
=
start
;
open_load
->
context
.
end
=
end
;
open_load
->
context
.
types
=
types
;
if
(
sequence_server
)
initial_request
->
request
=
ZMAP_PROTOCOLREQUEST
_FEATURE_SEQUENCE
;
open_load
->
features
.
type
=
ZMAP_SERVERREQ
_FEATURE_SEQUENCE
;
else
initial_request
->
request
=
ZMAP_PROTOCOLREQUEST_FEATURES
;
}
open_load
->
features
.
type
=
ZMAP_SERVERREQ_FEATURES
;
/* in the end the types files will be optional..... */
types
=
zMapFeatureTypeGetFromFile
(
types_file
)
;
if
((
connection
=
zMapConnCreate
(
machine
,
port
,
protocol
,
timeout
,
version
,
sequence
,
start
,
end
,
types
,
(
ZMapProtocolAny
)
initial_request
)))
{
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
if
((
thread
=
zMapThreadCreate
(
machine
,
port
,
protocol
,
timeout
,
version
,
sequence
,
start
,
end
,
types
,
(
void
*
)
open_load
)))
;
#endif
/* ED_G_NEVER_INCLUDE_THIS_CODE */
zMapThreadRequest
(
thread
,
(
void
*
)
open_load
)
;
view_con
=
g_new0
(
ZMapViewConnectionStruct
,
1
)
;
view_con
->
sequence_server
=
sequence_server
;
...
...
@@ -1289,14 +1331,9 @@ static ZMapViewConnection createConnection(ZMapView zmap_view,
view_con
->
parent_view
=
zmap_view
;
/* If we are asking the thread to get the features when it starts up then we must record
* that we have made a request. */
if
(
load_features
)
view_con
->
curr_request
=
ZMAP_REQUEST_GETDATA
;
else
view_con
->
curr_request
=
ZMAP_REQUEST_WAIT
;
view_con
->
curr_request
=
ZMAPTHREAD_REQUEST_EXECUTE
;
view_con
->
connection
=
connection
;
view_con
->
thread
=
thread
;
}
return
view_con
;
...
...
@@ -1306,7 +1343,7 @@ static void destroyConnection(ZMapViewConnection *view_conn_ptr)
{
ZMapViewConnection
view_conn
=
*
view_conn_ptr
;
zMap
Conn
Destroy
(
view_conn
->
connection
)
;
zMap
Thread
Destroy
(
view_conn
->
thread
)
;
/* Need to destroy the types array here....... */
...
...
@@ -1433,9 +1470,8 @@ static void freeContext(ZMapFeatureContext feature_context)
* the diff we should not free the data but should free all our structs...
*
* */
static
void
getFeatures
(
ZMapView
zmap_view
,
ZMap
ProtocolAny
req_any
)
static
void
getFeatures
(
ZMapView
zmap_view
,
ZMap
ServerReqGetFeatures
feature_req
)
{
ZMapProtocolGetFeatures
feature_req
=
(
ZMapProtocolGetFeatures
)
req_any
;
ZMapFeatureContext
new_features
=
NULL
,
diff_context
=
NULL
;
/* Merge new data with existing data (if any). */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment