ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/rt/RdataShareMap.cpp
(Generate patch)

Comparing ray/src/rt/RdataShareMap.cpp (file contents):
Revision 2.2 by greg, Wed Oct 30 01:38:21 2024 UTC vs.
Revision 2.6 by greg, Wed Nov 12 20:51:14 2025 UTC

# Line 68 | Line 68 | RdataShareMap::RdataShareMap(const char *name, int fla
68                          else if (fstat(fd, &sbuf) >= 0)
69                                  siz = sbuf.st_size;
70                          else {
71 <                                sprintf(errmsg, "cannot stat '%s'", chName);
71 >                                sprintf(errmsg, "cannot stat '%s'", name);
72                                  error(SYSTEM, errmsg);
73                                  close(fd);
74                                  return;
# Line 80 | Line 80 | RdataShareMap::RdataShareMap(const char *name, int fla
80                          return;
81                  }
82          }
83 <        mmorg = (void *)mmap(NULL, siz, mmprot,
83 >        if (siz) mmorg = (void *)mmap(NULL, siz, mmprot,
84                                  MAP_SHARED|(name ? MAP_FILE : MAP_ANON), fd, 0);
85          close(fd);
86          if (mmorg == MAP_FAILED) {
# Line 107 | Line 107 | RdataShareMap::~RdataShareMap()
107   size_t
108   RdataShareMap::Resize(size_t new_siz)
109   {
110        if (!mmorg)
111                return 0;
110          if (new_siz > 0) {
111                  if (new_siz == osiz)
112                          return osiz;
# Line 143 | Line 141 | RdataShareMap::Resize(size_t new_siz)
141                  new_siz = sbuf.st_size;
142          }
143          if (new_siz > osiz) {           // need to extend & remap
144 <                int     fd = open(chName, mode&RDSread ? O_RDWR : O_WRONLY);
144 >                int     fd = open(chName, O_RDWR);
145                  if (fd < 0) {
146                          sprintf(errmsg, "cannot reopen '%s'", chName);
147                          error(SYSTEM, errmsg);
# Line 155 | Line 153 | RdataShareMap::Resize(size_t new_siz)
153                          close(fd);
154                          return 0;
155                  }
156 <                munmap(mmorg, osiz);
156 >                if (mmorg) munmap(mmorg, osiz);
157                  mmorg = mmap(NULL, new_siz,
158                                  mode&RDSread ? PROT_READ|PROT_WRITE : PROT_WRITE,
159                                  MAP_SHARED|MAP_FILE, fd, 0);
# Line 167 | Line 165 | RdataShareMap::Resize(size_t new_siz)
165                          return osiz = 0;
166                  }
167          } else if (truncate(chName, new_siz) < 0) {
168 <                sprintf(errmsg, "cannot truncate '%s'", chName);
168 >                sprintf(errmsg, "cannot resize '%s'", chName);
169                  return 0;
170          }
171          return osiz = new_siz;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)