From 5fb54566d2837e951245f151da803678949f8802 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 8 Mar 2000 22:01:02 +0000 Subject: [PATCH] Added server protocol version check. --- include/server.h | 3 +++ scheduler/client.c | 6 ++++++ server/thread.c | 1 + server/trace.c | 3 ++- tools/make_requests | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/server.h b/include/server.h index 28c5199ac1b..5f47c181fcc 100644 --- a/include/server.h +++ b/include/server.h @@ -188,6 +188,7 @@ struct get_thread_buffer_request OUT void* pid; /* process id of the new thread's process */ OUT void* tid; /* thread id of the new thread */ OUT int boot; /* is this the boot thread? */ + OUT int version; /* protocol version */ }; @@ -1185,6 +1186,8 @@ enum request REQ_NB_REQUESTS }; +#define SERVER_PROTOCOL_VERSION 1 + /* ### make_requests end ### */ /* Everything above this line is generated automatically by tools/make_requests */ diff --git a/scheduler/client.c b/scheduler/client.c index 27d4d1b06ea..e78c92d52bd 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -467,6 +467,12 @@ int CLIENT_InitThread(void) first_req = teb->buffer; teb->process->server_pid = first_req->pid; teb->tid = first_req->tid; + if (first_req->version != SERVER_PROTOCOL_VERSION) + server_protocol_error( "version mismatch %d/%d.\n" + "Your %s binary was not upgraded correctly,\n" + "or you have an older one somewhere in your PATH.\n", + first_req->version, SERVER_PROTOCOL_VERSION, + (first_req->version > SERVER_PROTOCOL_VERSION) ? "wine" : "wineserver" ); if (first_req->boot) boot_thread_id = teb->tid; else if (boot_thread_id == teb->tid) boot_thread_id = 0; diff --git a/server/thread.c b/server/thread.c index 14d7ea649da..8f30280e183 100644 --- a/server/thread.c +++ b/server/thread.c @@ -104,6 +104,7 @@ static int alloc_client_buffer( struct thread *thread ) req->pid = get_process_id( thread->process ); req->tid = get_thread_id( thread ); req->boot = (thread == booting_thread); + req->version = SERVER_PROTOCOL_VERSION; set_reply_fd( thread, fd ); send_reply( thread ); return 1; diff --git a/server/trace.c b/server/trace.c index 2bdecde93a6..eaf479353f6 100644 --- a/server/trace.c +++ b/server/trace.c @@ -282,7 +282,8 @@ static void dump_get_thread_buffer_reply( const struct get_thread_buffer_request { fprintf( stderr, " pid=%p,", req->pid ); fprintf( stderr, " tid=%p,", req->tid ); - fprintf( stderr, " boot=%d", req->boot ); + fprintf( stderr, " boot=%d,", req->boot ); + fprintf( stderr, " version=%d", req->version ); } static void dump_terminate_process_request( const struct terminate_process_request *req ) diff --git a/tools/make_requests b/tools/make_requests index 8e608ccf52c..9e84e793472 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -30,10 +30,12 @@ open(SERVER,"include/server.h") or die "Can't open include/server.h"; ### Parse server.h to find request/reply structure definitions my @trace_lines = (); +my $protocol = 0; # server protocol version while () { if (/^struct +(\w+)_request/) { &DO_REQUEST($1); } + if (/^\#define SERVER_PROTOCOL_VERSION (\d+)/) { $protocol = $1 + 1; } } ### Output the dumping function tables @@ -68,6 +70,7 @@ my @server_lines = (); push @server_lines, "enum request\n{\n"; foreach $req (@requests) { push @server_lines, " REQ_\U$req,\n"; } push @server_lines, " REQ_NB_REQUESTS\n};\n"; +push @server_lines, "\n#define SERVER_PROTOCOL_VERSION $protocol\n"; REPLACE_IN_FILE( "include/server.h", @server_lines );