From dd6821cecb681c301c75242ced54946469f5a814 Mon Sep 17 00:00:00 2001 From: eddyem Date: Mon, 2 Nov 2015 08:50:34 +0300 Subject: [PATCH] test version --- .gitignore | 4 ++++ bta_control.c | 3 ++- bta_shdata.c | 12 ++++++------ bta_shdata.h | 14 +++++++------- 4 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c514bfd --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.hg* +*.tgz +*~ +.dropbox.attr diff --git a/bta_control.c b/bta_control.c index 4e5587d..0f0e1a2 100644 --- a/bta_control.c +++ b/bta_control.c @@ -684,7 +684,7 @@ int main(int argc, char **argv){ if(showinfo != NO_INFO) bta_print(showinfo, GP->infoargs); else if(GP->listinfo) bta_print(NO_INFO, NULL); // show arguments available #define RUN(arg) do{if(!arg) retcode = 1;}while(0) -#define RUNBLK(arg) do{if(!arg) return 1;}while(0) +#define RUNBLK(arg) do{if(!arg){retcode = 1; goto restoring;}}while(0) if(GP->telstop) RUN(stop_telescope()); if(GP->eqcrds) RUNBLK(setCoords(GP->eqcrds, TRUE)); else if(GP->horcrds) RUNBLK(setCoords(GP->horcrds, FALSE)); @@ -700,6 +700,7 @@ int main(int argc, char **argv){ else if(GP->corrRAD) RUN(run_correction(GP->corrRAD, FALSE)); #undef RUN #undef RUNBLK +restoring: unlink(PIDFILE); restore_console(); return retcode; diff --git a/bta_shdata.c b/bta_shdata.c index 547d1b0..19367ca 100644 --- a/bta_shdata.c +++ b/bta_shdata.c @@ -13,10 +13,10 @@ static char msg[80]; #define PERR(...) do{sprintf(msg, __VA_ARGS__); perror(msg);} while(0) #ifndef BTA_MODULE -struct BTA_Data *sdt; -struct BTA_Local *sdtl; +volatile struct BTA_Data *sdt; +volatile struct BTA_Local *sdtl; -struct SHM_Block sdat = { +volatile struct SHM_Block sdat = { {"Sdat"}, sizeof(struct BTA_Data), 2048,0444, @@ -97,7 +97,7 @@ void bta_data_close() { /** * Allocate shared memory segment */ -int get_shm_block( struct SHM_Block *sb, int server) { +int get_shm_block(volatile struct SHM_Block *sb, int server) { int getsize = (server)? sb->maxsize : sb->size; // first try to find existing one sb->id = shmget(sb->key.code, getsize, sb->mode); @@ -135,7 +135,7 @@ int get_shm_block( struct SHM_Block *sb, int server) { return 1; } -int close_shm_block(struct SHM_Block *sb){ +int close_shm_block(volatile struct SHM_Block *sb){ int ret; if(sb->close != NULL) sb->close(); @@ -179,7 +179,7 @@ void get_cmd_queue(struct CMD_Queue *cq, int server){ #endif // BTA_MODULE -int check_shm_block( struct SHM_Block *sb) { +int check_shm_block(volatile struct SHM_Block *sb) { if(sb->check) return(sb->check()); else return(0); diff --git a/bta_shdata.h b/bta_shdata.h index 827712d..6a000ba 100644 --- a/bta_shdata.h +++ b/bta_shdata.h @@ -33,7 +33,7 @@ struct SHM_Block { uint8_t *addr; // connection address }; -extern struct SHM_Block sdat; +extern volatile struct SHM_Block sdat; /* * Command queue descriptor @@ -788,7 +788,7 @@ struct BTA_Data { uint32_t pep_code_di, pep_code_do; // dome PEP codes }; -extern struct BTA_Data *sdt; +extern volatile struct BTA_Data *sdt; /******************************************************************************* * Local data structure * @@ -819,7 +819,7 @@ struct my_msgbuf { char mtext[100]; // message itself }; -extern struct BTA_Local *sdtl; +extern volatile struct BTA_Local *sdtl; extern int snd_id; extern int cmd_src_pid; extern uint32_t cmd_src_ip; @@ -831,12 +831,12 @@ extern uint32_t cmd_src_ip; void bta_data_init(); int bta_data_check(); void bta_data_close(); -int get_shm_block( struct SHM_Block *sb, int server); -int close_shm_block(struct SHM_Block *sb); -void get_cmd_queue( struct CMD_Queue *cq, int server); +int get_shm_block(volatile struct SHM_Block *sb, int server); +int close_shm_block(volatile struct SHM_Block *sb); +void get_cmd_queue(struct CMD_Queue *cq, int server); #endif -int check_shm_block( struct SHM_Block *sb); +int check_shm_block(volatile struct SHM_Block *sb); void encode_lev_passwd(char *passwd, int nlev, uint32_t *keylev, uint32_t *codlev); int find_lev_passwd(char *passwd, uint32_t *keylev, uint32_t *codlev);