Changeset 745 for trunk/server/source3/smbd/connection.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/smbd/connection.c
r414 r745 19 19 20 20 #include "includes.h" 21 #include "smbd/smbd.h" 22 #include "smbd/globals.h" 23 #include "dbwrap.h" 24 #include "auth.h" 21 25 22 26 /**************************************************************************** … … 31 35 DEBUG(3,("Yielding connection to %s\n",name)); 32 36 33 if (!(rec = connections_fetch_entry(NULL, conn, name))) { 37 rec = connections_fetch_entry(talloc_tos(), conn, name); 38 if (rec == NULL) { 34 39 DEBUG(0, ("connections_fetch_entry failed\n")); 35 40 return False; … … 48 53 49 54 struct count_stat { 50 pid_t mypid;51 55 int curr_connections; 52 56 const char *name; … … 99 103 struct count_stat cs; 100 104 101 cs.mypid = sys_getpid();102 105 cs.curr_connections = 0; 103 106 cs.name = sharename; … … 119 122 120 123 /**************************************************************************** 121 Count the number of connections open across all shares.122 ****************************************************************************/123 124 int count_all_current_connections(void)125 {126 return count_current_connections(NULL, True /* clear stale entries */);127 }128 129 /****************************************************************************130 124 Claim an entry in the connections database. 131 125 ****************************************************************************/ 132 126 133 bool claim_connection(connection_struct *conn, const char *name, 134 uint32 msg_flags) 127 bool claim_connection(connection_struct *conn, const char *name) 135 128 { 136 129 struct db_record *rec; … … 138 131 TDB_DATA dbuf; 139 132 NTSTATUS status; 140 char addr[INET6_ADDRSTRLEN];141 133 142 134 DEBUG(5,("claiming [%s]\n", name)); … … 150 142 ZERO_STRUCT(crec); 151 143 crec.magic = 0x280267; 152 crec.pid = procid_self(); 153 crec.cnum = conn?conn->cnum:-1; 154 if (conn) { 155 crec.uid = conn->server_info->utok.uid; 156 crec.gid = conn->server_info->utok.gid; 157 strlcpy(crec.servicename, lp_servicename(SNUM(conn)), 158 sizeof(crec.servicename)); 159 } 144 crec.pid = sconn_server_id(conn->sconn); 145 crec.cnum = conn->cnum; 146 crec.uid = conn->session_info->utok.uid; 147 crec.gid = conn->session_info->utok.gid; 148 strlcpy(crec.servicename, lp_servicename(SNUM(conn)), 149 sizeof(crec.servicename)); 160 150 crec.start = time(NULL); 161 crec.bcast_msg_flags = msg_flags;162 151 163 152 strlcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)); 164 strlcpy(crec.addr,conn?conn->client_address: 165 client_addr(get_client_fd(),addr,sizeof(addr)), 166 sizeof(crec.addr)); 153 strlcpy(crec.addr, conn->sconn->client_id.addr, sizeof(crec.addr)); 167 154 168 155 dbuf.dptr = (uint8 *)&crec; … … 181 168 return True; 182 169 } 183 184 bool register_message_flags(bool doreg, uint32 msg_flags)185 {186 struct db_record *rec;187 struct connections_data *pcrec;188 NTSTATUS status;189 190 DEBUG(10,("register_message_flags: %s flags 0x%x\n",191 doreg ? "adding" : "removing",192 (unsigned int)msg_flags ));193 194 if (!(rec = connections_fetch_entry(NULL, NULL, ""))) {195 DEBUG(0, ("connections_fetch_entry failed\n"));196 return False;197 }198 199 if (rec->value.dsize != sizeof(struct connections_data)) {200 DEBUG(0,("register_message_flags: Got wrong record size\n"));201 TALLOC_FREE(rec);202 return False;203 }204 205 pcrec = (struct connections_data *)rec->value.dptr;206 if (doreg)207 pcrec->bcast_msg_flags |= msg_flags;208 else209 pcrec->bcast_msg_flags &= ~msg_flags;210 211 status = rec->store(rec, rec->value, TDB_REPLACE);212 213 if (!NT_STATUS_IS_OK(status)) {214 DEBUG(0,("register_message_flags: tdb_store failed: %s.\n",215 nt_errstr(status)));216 TALLOC_FREE(rec);217 return False;218 }219 220 DEBUG(10,("register_message_flags: new flags 0x%x\n",221 (unsigned int)pcrec->bcast_msg_flags ));222 223 TALLOC_FREE(rec);224 225 return True;226 }
Note:
See TracChangeset
for help on using the changeset viewer.