[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Google
 
Web openvpn.net

Re: [Openvpn-users] Bug in status.c when building with VC


  • Subject: Re: [Openvpn-users] Bug in status.c when building with VC
  • From: James Yonan <jim@xxxxxxxxx>
  • Date: Tue, 7 Dec 2004 19:15:21 -0700 (MST)

On Tue, 7 Dec 2004, Blaine Fleming wrote:

> I recently ran into a bug when using the --status option on windows with a 
> MSVC generated binary.  The problem is that the status file is created as 
> read-only.  This is fine when the file is first created and works until the 
> tunnel is stopped.  When the tunnel is restarted, openvpn is unable to open 
> the file for writing because it is read only.  The problem originates with 
> the difference between mingw and msvc.  In msvc, S_IRUSR and S_IWUSR are 
> not available but _S_IREAD and _S_IWRITE are.  Below is the MSVC patched 
> version of status_open in status.c from beta20.  This was a quick patch but 
> it seems to have fixed the problem.
> 
> status_open (const char *filename,
> 	     const int refresh_freq,
> 	     const int msglevel,
> 	     const struct virtual_output *vout,
> 	     const unsigned int flags)
> {
>    struct status_output *so = NULL;
>    if (filename || msglevel >= 0 || vout)
>      {
>        ALLOC_OBJ_CLEAR (so, struct status_output);
>        so->flags = flags;
>        so->msglevel = msglevel;
>        so->vout = vout;
>        so->fd = -1;
>        buf_reset (&so->read_buf);
>        event_timeout_clear (&so->et);
>        if (filename)
> 	{
> 	  switch (so->flags)
> 	    {
> #ifdef _MSC_VER
> 	    case STATUS_OUTPUT_WRITE:
> 	      so->fd = open (filename,
> 			     O_CREAT | O_TRUNC | O_WRONLY,
> 				 _S_IREAD | _S_IWRITE);
> 	      break;
> 	    case STATUS_OUTPUT_READ:
> 	      so->fd = open (filename,
> 			     O_RDONLY,
> 				 _S_IREAD | _S_IWRITE);
> 	      break;
> 	    case STATUS_OUTPUT_READ|STATUS_OUTPUT_WRITE:
> 	      so->fd = open (filename,
> 			     O_CREAT | O_RDWR,
> 				 _S_IREAD | _S_IWRITE);
> 	      break;
> #else
> 	    case STATUS_OUTPUT_WRITE:
> 	      so->fd = open (filename,
> 			     O_CREAT | O_TRUNC | O_WRONLY,
> 			     S_IRUSR | S_IWUSR);
> 	      break;
> 	    case STATUS_OUTPUT_READ:
> 	      so->fd = open (filename,
> 			     O_RDONLY,
> 			     S_IRUSR | S_IWUSR);
> 	      break;
> 	    case STATUS_OUTPUT_READ|STATUS_OUTPUT_WRITE:
> 	      so->fd = open (filename,
> 			     O_CREAT | O_RDWR,
> 			     S_IRUSR | S_IWUSR);
> 	      break;
> #endif
> 		default:
> 	      ASSERT (0);
> 	    }
> 	  if (so->fd >= 0)
> 	    {
> 	      so->filename = string_alloc (filename, NULL);
> 	      /* allocate read buffer */
> 	      if (so->flags & STATUS_OUTPUT_READ)
> 		so->read_buf = alloc_buf (512);
> 	    }
> 	  else
> 	    {
> 	      msg (M_WARN, "Note: cannot open %s for %s", filename, 
> print_status_mode (so->flags));
> 	      so->errors = true;
> 	    }
> 	}
>        else
> 	so->flags = STATUS_OUTPUT_WRITE;
>        if ((so->flags & STATUS_OUTPUT_WRITE) && refresh_freq > 0)
> 	{
> 	  event_timeout_init (&so->et, refresh_freq, 0);
> 	}
>      }
>    return so;
> }

Okay, I will merge this for 2.0-rc2.

> On a slightly related note, the file size and performance on the MSVC 
> version seems to be much better on windows.

Interesting.  Can you provide more details such as file size differences?

What sort of metrics did you use to compare performance, and how did the 
numbers stack up?

> Is there any interest in a 
> binary version being available for download?

If the performance differences are significant, I would be happy to use
MSVC for the Windows builds if someone is willing to donate a copy.

If you'd like to make MSVC-built binaries available, that would be great 
too.

James

____________________________________________
Openvpn-users mailing list
Openvpn-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/openvpn-users