1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-06 07:44:57 +03:00

v4.19-9605-beta

This commit is contained in:
dnobori
2016-03-06 23:16:01 +09:00
parent d3a1b26413
commit 17e624ac26
240 changed files with 839 additions and 706 deletions

View File

@ -3,9 +3,9 @@
//
// SoftEther VPN Server, Client and Bridge are free software under GPLv2.
//
// Copyright (c) 2012-2015 Daiyuu Nobori.
// Copyright (c) 2012-2015 SoftEther VPN Project, University of Tsukuba, Japan.
// Copyright (c) 2012-2015 SoftEther Corporation.
// Copyright (c) 2012-2016 Daiyuu Nobori.
// Copyright (c) 2012-2016 SoftEther VPN Project, University of Tsukuba, Japan.
// Copyright (c) 2012-2016 SoftEther Corporation.
//
// All Rights Reserved.
//
@ -2478,9 +2478,12 @@ UINT ReadFifo(FIFO *f, void *p, UINT size)
f->total_read_size += (UINT64)read_size;
if (f->size == 0)
if (f->fixed == false)
{
f->pos = 0;
if (f->size == 0)
{
f->pos = 0;
}
}
ShrinkFifoMemory(f);
@ -2500,6 +2503,11 @@ void ShrinkFifoMemory(FIFO *f)
return;
}
if (f->fixed)
{
return;
}
// Rearrange the memory
if (f->pos >= FIFO_INIT_MEM_SIZE &&
f->memsize >= fifo_current_realloc_mem_size &&
@ -2520,6 +2528,25 @@ void ShrinkFifoMemory(FIFO *f)
}
}
// Write data to the front of FIFO
void WriteFifoFront(FIFO *f, void *p, UINT size)
{
// Validate arguments
if (f == NULL || size == 0)
{
return;
}
if (f->pos < size)
{
PadFifoFront(f, size - f->pos);
}
Copy(((UCHAR *)f->p) + (f->pos - size), p, size);
f->pos -= size;
f->size += size;
}
// Write to the FIFO
void WriteFifo(FIFO *f, void *p, UINT size)
{
@ -2560,6 +2587,20 @@ void WriteFifo(FIFO *f, void *p, UINT size)
KS_INC(KS_WRITE_FIFO_COUNT);
}
// Add a padding before the head of fifo
void PadFifoFront(FIFO *f, UINT size)
{
// Validate arguments
if (f == NULL || size == 0)
{
return;
}
f->memsize += size;
f->p = ReAlloc(f->p, f->memsize);
}
// Clear the FIFO
void ClearFifo(FIFO *f)
{
@ -2678,6 +2719,10 @@ FIFO *NewFifoFast()
return NewFifoEx(true);
}
FIFO *NewFifoEx(bool fast)
{
return NewFifoEx2(fast, false);
}
FIFO *NewFifoEx2(bool fast, bool fixed)
{
FIFO *f;
@ -2698,6 +2743,7 @@ FIFO *NewFifoEx(bool fast)
f->size = f->pos = 0;
f->memsize = FIFO_INIT_MEM_SIZE;
f->p = Malloc(FIFO_INIT_MEM_SIZE);
f->fixed = false;
#ifndef DONT_USE_KERNEL_STATUS
// TrackNewObj(POINTER_TO_UINT64(f), "FIFO", 0);