
#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<netinet/in.h>
#include<string.h>
#include<stdlib.h>
#include<signal.h>
#include<pthread.h>

#include"zither.h"
#include<almemsys/almemsys.h>
#include"jpreturn.h"
#include<file_comp/file_comp.h>

extern global_data_t gd;
extern pthread_mutex_t name_mutex;


int th_miname_dump(void) 
{
int ret;

for(;;){

   #ifdef MID_BUG
   printf("MID_BUG: th_miname_dump(): start loop int =%d\n", gd.td.midint);
   #endif

   safe_pthread_mutex_lock(&name_mutex);

   if(gd.td.midint < 60){
      gd.td.midint = 60;
      }

   ret = miname_dump(gd.fi.midump_filename_2);
   #ifdef MID_BUG
   fprintf(stderr,"MID_BUG: th_miname_dump(): sleep time =%d, return  %d = miname_dump(void);\n", gd.td.midint, ret);
   #endif

   pthread_mutex_unlock(&name_mutex);

   #ifdef MID_BUG
   printf("MID_BUG: th_miname_dump(): stop loop int =%d\n", gd.td.midint);
   #endif

   sleep(gd.td.midint);

   #ifdef MID_BUG
   printf("MID_BUG: th_miname_dump(): loop out loop int =%d\n", gd.td.midint);
   #endif
   }

return 0;
}





